wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

2F-1 | Python Quiz | 14/10/2024

Total questions: 20

Worksheet time: 20mins

Name
Class
Date
1.

What will the following code print? print("Hello", "World", sep="-")

a)

Hello-World

b)

Hello World

c)

Hello- World

d)

Hello -World

2.

Which of these functions is used to get input from the user in Python?

a)

print()

b)

input()

c)

int()

d)

float()

3.

What is the result of 5 // 2 in Python?

a)

2.5

b)

2

c)

3

d)

2.0

4.

What does the end parameter in the print() function do?

a)

Changes the default separator

b)

Ends the program

c)

Specifies what is printed at the end

d)

Adds a new line at the end

5.

Which operator is used for exponentiation in Python?

a)

/

b)

*

c)

**

d)

%

6.

What is the output of print(int(3.7))?

a)

3

b)

4

c)

3.7

d)

Error

7.

What will print("A", "B", "C", sep="*") output?

a)

A*B*C

b)

ABC

c)

A B C

d)

A* B* C

8.

What will int("5.2") result in?

a)

5

b)

5.2

c)

Error

d)

6

9.

Which of the following can be used to convert a string s to a floating-point number?

a)

int(s)

b)

float(s)

c)

str(s)

d)

input(s)

10.

What will be the result of print(10 // 3)?

a)

3.33

b)

3

c)

10

d)

0

11.

What is the output of print("Hello", end="!") followed by print("World")?

a)

Hello!World

b)

Hello World!

c)

Hello! World

d)

HelloWorld!

12.

Which statement will correctly check if a number n is positive in Python?

a)

if n > 0:

b)

if n >= 0:

c)

if n 2: print("Yes") elif 3 > 1: print("Maybe") else: print("No")

13.

What will the output be for print("Hello", end="*") followed by print("Python", sep="*")?

a)

Hello*Python

b)

HelloPython*

c)

Hello*Python*

d)

HelloPython

14.

What will the result of input("Enter a number: ") be if the user enters 5?

a)

5

b)

"5"

c)

int

d)

float

15.

What is the output of print(7 % 3)?

a)

1

b)

2

c)

3

d)

0

16.

Which of these will convert the string "123" to an integer and add 5 to it?

a)

str(123) + 5

b)

int("123") + 5

c)

float("123") + 5

d)

input("123") + 5

17.

Which of the following is the correct way to use elif in an if statement?

a)

if condition: ... else if condition: ...

b)

if condition: ... elif condition: ...

c)

else if condition: ...

d)

if condition: ... elseif condition: ...

18.

What does float("5.67") return?

a)

5

b)

5.67

c)

"5.67"

d)

Error

19.

What will if 4 > 2: print("Yes") elif 3 > 1: print("Maybe") else: print("No") output?

a)

Yes Maybe

b)

Yes

c)

Maybe

d)

No

20.

Which of these expressions will result in False?

a)

5 < 10

b)

3 == 3

c)

4 != 4

d)

2 <= 5