NEW
Font size
WorksheetsSDH QUJWEQSDASAK<D(Python)
Total questions: 43
Worksheet time: 22mins
Which of the following is a valid variable name in Python?
2var
_myVar
my-var
class
What will type(3.14) return?
int
float
str
bool
What is the result of 3 * 4 + 2?
14
18
20
10
Which operator is used for exponentiation in Python?
^
**
%%
//
What does bool(0) evaluate to?
True
False
0
Error
Which of these is a Python keyword?
return
main
loop
What is the result of int("10") + 5?
"105"
15
"10 5"
Error
What will print(10 == "10") output?
True
False
10
Error
Which function is used to convert a value to a string?
str()
string()
val()
chr()
What is the result of not(True and False)?
True
False
None
Error
What does "hello".upper() return?
"HELLO"
"hello"
"Hello"
Error
Which of the following is an assignment statement?
x + 5
x == 5
x = 5
print(x)
What is the value of x after x = 5; x += 3?
5
8
3
15
What will bool("") return?
True
False
""
Error
Which of these is NOT a valid type conversion?
int("5")
str(5.5)
float("five")
bool(1)
What will this code output? text x = 10 if x > 5: print("A") else: print("B")
A
B
Nothing
Error
Which keyword is used for multi-way decisions in Python?
switch
case
elif
elseif
What is the output of: text a = 5 b = 10 if a > b: print("More") else: print("Less")
More
Less
5
10
What does pass do in an if block?
Skips the condition
Ends the program
Does nothing (placeholder)
Prints "pass"
How many elif blocks can you have?
Only 1
Up to 3
As many as needed
None
What is the output of: text age = 18 if age >= 18: print("Adult") else: print("Minor")
Adult
Minor
18
Error
What will this print? text x = 0 if x: print("Yes") else: print("No")
Yes
No
0
Error
Which logical operator means "both must be true"?
or
and
not
xor
What is the result of (5 > 3) and (2 == 4)?
True
False
5
Error
What will this code output? text score = 85 if score >= 90: print("A") elif score >= 80: print("B") else: print("C")
A
B
C
None
Which is the correct syntax for nested if?
if (if):
if inside if:
if condition: if condition:
if condition: # nested if inside
What does != mean?
Equal to
Not equal to
Less than
Greater than
What will print(10 2: print("Big") elif x > 3: print("Medium")
Big
Medium
Nothing
Error
Which keyword defines a function in Python?
def
function
func
define
What is the output of: text def greet(): return "Hello" print(greet())
Hello
None
Error
greet()
What does return do?
Prints a value
Ends the function and sends back a value
Starts a loop
Defines a variable
Which is a built-in Python function?
calculate()
input()
loop()
check()
What will this code output? text def add(a, b): return a + b print(add(2, 3))
5
23
None
Error
What is a "fruitful function"?
A function that prints
A function that returns a value
A function with no parameters
A function that loops
What is the default return value of a function without return?
0
None
False
""
What does max("Hello") return?
'H'
'o'
'e'
'l'
What will this output? text def change(x): x = 10 y = 5 change(y) print(y)
5
10
None
Error
What is a parameter?
A value sent to a function
A function's return value
A local variable
A built-in function
What does len([1,2,3]) return?
3
6
[1,2,3]
Error
What is the output of: text def multi(a, b=2): return a * b print(multi(3))
6
5
Error
None
Which is true about Python's argument passing?
Always pass by value
Always pass by reference
Pass by object reference
Pass by copy
What will this code print? text def test(): print("Inside") print(test())
Inside
Inside None
None
Error
What is the purpose of *args in a function?
To accept keyword arguments
To accept variable-length arguments
To return multiple values
To end the function
