Does indentation matter in Python?
Yes
Does this loop execute:
x = 5
while x < 5:
#body
No, x is not < 5
What are the three types of decisions structures?
if, elif, and else
What are the three data types?
int, float, and string
Outside the main function
What is the correct way to format input when taking in an integer?
int(input("words"))
How many "Hello"'s would be printed in this loop:
x = 1
while x < 10:
print("Hello")
x += 1
10
Is the following code correct?
name="Hebah"
if name=="Kelly":
print ("Your name is Kelly")
if name=="Hebah":
print ("Your name is Hebah")
else :
print ("Your name is Maanas")
No. The second statement should be elif.
Write the code to input a number into a variable.
variable_name= int(input ("Enter in a number"))
What will output?
def function():
print("Hello")
def main():
print("Hi")
main()
Hi
Is this correct:
if x < 3
#body
No, missing colon
What is the correct way to format while True (to make sure it does not go on forever)?
while True:
#body
if condition:
break
x=5
if x<10:
print ("x is less than 10")
else x>=10:
print ("x is greater than or equal to 10")
No
What is the difference between int and float?
float is decimals
What keyword do you use to pass something back to the main function?
return
Is this correct:
(int(input("words")))
No, too many parentheses
What would be the output of this line of code?
print (list (range (2, 11, 2)))
2
4
6
8
10
What is wrong with the following code?
y=7
if y<8:
print ("Small")
else:
print ("Big")
The else statement shouldn't be indented.
How do you convert from a string to a float?
float ()
What is wrong with the following code:
def function (name, age, grade):
#body
def main():
function("Kelly", 16)
main()
different number of parameters in function call
Is this function call correct?
def function(parameter):
#body
def main():
function()
No, the function call has no parameter, but the definition does
What is the correct output for this line of code?
for x in range in (2):
print (x)
for c in "ab":
print (c)
0
a
b
1
a
b
What is the output of the following code?
x=13
if x>20:
if x<25:
if x<=23:
if x * 3 < 69:
print(x + 5)
else:
print(x + 3)
16
What is the output:
x = 5.1
product = int(x) * 2
print(product)
10
What is the output of the following code:
def function (x):
x = x + 2
return x
def main():
x = 5
function(x)
print(x)
main()
5