This variable type stores decimal numbers
Float
This type of loop runs forever as long as a condition is True
while
All functions/methods are required to have this
Parenthesis
To document code (or multiline comment) we use what?
"""
"""
(triple quotation start and end)
Write an if statement that checks if a number is positive.
if(num > 0):
This method always returns a string from user data.
input()
What keyword stops a loop immediately?
break
This method/function returns the number of characters in a string
len()
Since it's not compiled, Python is this type of language.
Interpreted / Scripted
word = "burger king"
what is the code needed to output "burger" and "king" on 2 separate lines.
print(word[0:6])
print(word[7:])
num = int(num)
What is the purpose of this python statement?
Turn the variable number into an integer datatype
for i in range(0,5):
print(i, end="")
What is the output of this for loop?
01234
This method divides a string into a list of substrings based on a specific delimiter.
split()
This category of error is often the most difficult to find as there are never any error messages shown by the interpreter
Logic errors
Write a branching statement that outputs the word "FizzBuzz" if a number is a multiple of both 3 and 5
if(num % 3 == 0 and num % 5 == 0):
print("FizzBuzz")
What is the point of the parameter "end=" within the print() function?
controls what is appended to the end of the output
This operator allows us to loop through a container of data
in
This function returns False if all characters in a string are not upper or lowercase letters, or numbers 0-9
isalnum()
word = "gulf coast"
print(word[20])
This code demonstrates what error?
Runtime error
Write a loop that validates a variable to be a number that's in range between 0 and 10
while not num.isdigit() or int(num) <= 0 or int(num) >= 10:
x = "hello" y = "world"
What does print(x[1:],y)
ello world
for letter in "dog":
print(letter)
What is the above output?
d
o
g
This method would be used to swap every instance of a substring for another
replace()
number = 5
if(number = 5)
print("Yes")
What are 2 issues with this code?
we use == for if statement comparison
missing colon after if statement
Code a loop that sums all even numbers between 0 and 100
total = 0
for x in range(0,101,2):
total += x
print(total)