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
This character is found at the beginning of a comment
#
This statement checks the validity of a statement before creating a branch/new decision
If statement
This function 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
write an if statement thats check if a number is positive
if(num > 0):
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()
These are the three categories of errors in programming
Syntax, Runtime, & Logic errors
This modulo expression checks for even numbers
number % 2 == 0
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 True if all characters in a string are upper or lowercase letters, or numbers 0-9
isalnum()
word = "burger king"
print(word[20])
This code demonstrates what error?
Runtime error
Why does this code cause an error?
age = input("Enter your age: ")
if age >= 21:
print("You may have a drink")
input() gives a string. must convert age with int()
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
Write an input validation loop that asks the user to enter only a number between 1 and 20
while not(num.isdigit() and 1 < int(num) < 20):