wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

SDH QUJWEQSDASAK<D(Python)

Total questions: 43

Worksheet time: 22mins

Name
Class
Date
1.

Which of the following is a valid variable name in Python?

a)

2var

b)

_myVar

c)

my-var

d)

class

2.

What will type(3.14) return?

a)

int

b)

float

c)

str

d)

bool

3.

What is the result of 3 * 4 + 2?

a)

14

b)

18

c)

20

d)

10

4.

Which operator is used for exponentiation in Python?

a)

^

b)

**

c)

%%

d)

//

5.

What does bool(0) evaluate to?

a)

True

b)

False

c)

0

d)

Error

6.

Which of these is a Python keyword?

a)

print

b)

return

c)

main

d)

loop

7.

What is the result of int("10") + 5?

a)

"105"

b)

15

c)

"10 5"

d)

Error

8.

What will print(10 == "10") output?

a)

True

b)

False

c)

10

d)

Error

9.

Which function is used to convert a value to a string?

a)

str()

b)

string()

c)

val()

d)

chr()

10.

What is the result of not(True and False)?

a)

True

b)

False

c)

None

d)

Error

11.

What does "hello".upper() return?

a)

"HELLO"

b)

"hello"

c)

"Hello"

d)

Error

12.

Which of the following is an assignment statement?

a)

x + 5

b)

x == 5

c)

x = 5

d)

print(x)

13.

What is the value of x after x = 5; x += 3?

a)

5

b)

8

c)

3

d)

15

14.

What will bool("") return?

a)

True

b)

False

c)

""

d)

Error

15.

Which of these is NOT a valid type conversion?

a)

int("5")

b)

str(5.5)

c)

float("five")

d)

bool(1)

16.

What will this code output? text x = 10 if x > 5: print("A") else: print("B")

a)

A

b)

B

c)

Nothing

d)

Error

17.

Which keyword is used for multi-way decisions in Python?

a)

switch

b)

case

c)

elif

d)

elseif

18.

What is the output of: text a = 5 b = 10 if a > b: print("More") else: print("Less")

a)

More

b)

Less

c)

5

d)

10

19.

What does pass do in an if block?

a)

Skips the condition

b)

Ends the program

c)

Does nothing (placeholder)

d)

Prints "pass"

20.

How many elif blocks can you have?

a)

Only 1

b)

Up to 3

c)

As many as needed

d)

None

21.

What is the output of: text age = 18 if age >= 18: print("Adult") else: print("Minor")

a)

Adult

b)

Minor

c)

18

d)

Error

22.

What will this print? text x = 0 if x: print("Yes") else: print("No")

a)

Yes

b)

No

c)

0

d)

Error

23.

Which logical operator means "both must be true"?

a)

or

b)

and

c)

not

d)

xor

24.

What is the result of (5 > 3) and (2 == 4)?

a)

True

b)

False

c)

5

d)

Error

25.

What will this code output? text score = 85 if score >= 90: print("A") elif score >= 80: print("B") else: print("C")

a)

A

b)

B

c)

C

d)

None

26.

Which is the correct syntax for nested if?

a)

if (if):

b)

if inside if:

c)

if condition: if condition:

d)

if condition: # nested if inside

27.

What does != mean?

a)

Equal to

b)

Not equal to

c)

Less than

d)

Greater than

28.

What will print(10 2: print("Big") elif x > 3: print("Medium")

a)

Big

b)

Medium

c)

Nothing

d)

Error

29.

Which keyword defines a function in Python?

a)

def

b)

function

c)

func

d)

define

30.

What is the output of: text def greet(): return "Hello" print(greet())

a)

Hello

b)

None

c)

Error

d)

greet()

31.

What does return do?

a)

Prints a value

b)

Ends the function and sends back a value

c)

Starts a loop

d)

Defines a variable

32.

Which is a built-in Python function?

a)

calculate()

b)

input()

c)

loop()

d)

check()

33.

What will this code output? text def add(a, b): return a + b print(add(2, 3))

a)

5

b)

23

c)

None

d)

Error

34.

What is a "fruitful function"?

a)

A function that prints

b)

A function that returns a value

c)

A function with no parameters

d)

A function that loops

35.

What is the default return value of a function without return?

a)

0

b)

None

c)

False

d)

""

36.

What does max("Hello") return?

a)

'H'

b)

'o'

c)

'e'

d)

'l'

37.

What will this output? text def change(x): x = 10 y = 5 change(y) print(y)

a)

5

b)

10

c)

None

d)

Error

38.

What is a parameter?

a)

A value sent to a function

b)

A function's return value

c)

A local variable

d)

A built-in function

39.

What does len([1,2,3]) return?

a)

3

b)

6

c)

[1,2,3]

d)

Error

40.

What is the output of: text def multi(a, b=2): return a * b print(multi(3))

a)

6

b)

5

c)

Error

d)

None

41.

Which is true about Python's argument passing?

a)

Always pass by value

b)

Always pass by reference

c)

Pass by object reference

d)

Pass by copy

42.

What will this code print? text def test(): print("Inside") print(test())

a)

Inside

b)

Inside None

c)

None

d)

Error

43.

What is the purpose of *args in a function?

a)

To accept keyword arguments

b)

To accept variable-length arguments

c)

To return multiple values

d)

To end the function