Font size
WorksheetsWeek2
Total questions: 8
Worksheet time: 5mins
3 + 4 * 2 // (1 - 5) ** 2
2
2.5
3
3.5
Reorder the following to get an output of 7
print(result)
x *= 2
x += 5
result = x // 3
x -= 3
x *= 2
x = 10
x -= 3
x += 5
result = x // 3
print(result)
x = 10
x -= 3
x *= 2
x += 5
result = x // 3
print(result)
x = 10
x += 5
x *= 2
x -= 3
result = x // 3
print(result)
x = 10
x *= 2
x -= 3
x += 5
result = x // 3
print(result)
After the following statements, what are the values of x and y?
x = 15
y = x
x = 22
x is 15 and y is 15
x is 22 and y is 22
x is 15 and y is 22
x is 22 and y is 15
Given the following variable names, identify which ones are invalid?
var$ible
_privatevar
2nd_variable
valid variable
print(2**3**2)
(a)
3 * str(2)+"simr"
(a)
Given this function:
def greet(name, greeting="Hello"):
return f"{greeting}, {name}!"
Match the correct function calling with their output
print(greet())
Error!
print(greet("Alice", "Hi"))
Hi, Alice!
print(greet("Bob"))
Hello, Bob!
print(greet)
<function greet at x>
def factorial(n):
if n == 1:
return 1
else:
return n * factorial(n - 1)
# Compute the factorial of 0
print(factorial(0))
Error
NAN
1
0
