What will be printed?
x = 10
y = x
x = 5
print(y)
What is 10 ?
What is the data type of the result: 3 + 2.0?
float
What keyword is used when the if condition is false and we want to try another condition?
elif
What keyword is used to start a loop that repeats a fixed number of times?
for
What symbol is used to create a list in Python?
Square brackets []
What is the output of:
x = 3
x += 2
print(x)
What is 5 ?
What will type([1, 2, 3]) return?
<class 'list' >
What keyword is used to catch all remaining cases after if and elif?
else
What keyword creates a loop that continues while a condition is true?
while
What is the index of the first item in a list?
0
What will be printed?
x, y = 2, 3
x, y = y, x
print(x, y)
3,2
What is the output of int("5") + float("3.2")?
8.2
What is printed?
x = 10
if x > 10:
print("Greater")
elif x == 10:
print("Equal")
else:
print("Smaller")
Equal
What does this print?
for i in range(3):
print(i)
0
1
2
What is the result of len([10, 20, 30, 40]) ?
4
If x = 10,
what does x = x * 2 + 5 make x equal to?
25
What will be the output of type("123") == type(123)?
False
What is the output?
x = 7
if x % 2 == 0:
print("Even")
elif x % 3 == 0:
print("Divisible by 3")
else:
print("Other")
Other
What is printed?
x = 5
while x > 0:
x -= 1
if x == 2:
continue
print(x)
4, 3, 1, 0
What is the output?
nums = [1, 2, 3]
for n in nums:
print(n * 2)
2
4
6
What type of error will this produce? print(x) without assigning x first
NameError
What will be printed?
x = None
print(type(x))
<class 'NoneType'>
What is the output?
x = -5
if x > 0:
print("Positive")
elif x == 0:
print("Zero")
elif x > -10:
print("Small Negative")
else:
print("Negative")
Small Negative
How many times would this get printed
for i in range(2):
for j in range(3):
print("*")
*
*
*
*
*
*
6 times
What is the output?
nums = [5, 8, 2, 9]
for n in nums:
if n % 2 == 0:
print(n)
8
2