wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Python Class 1

Total questions: 15

Worksheet time: 8mins

Name
Class
Date
1.

What is the correct syntax to print "Hello, World!" in Python?

a)

System.out.println("Hello, World!")

b)

echo "Hello, World!"

c)

print("Hello, World!")

d)

cout << "Hello, World!"

2.

What will be the output of the following code?

x = 5

y = 2

print(x % y)

a)

1

b)

2

c)

0

d)

5

3.

Which of the following data types is mutable in Python?

a)

Tuple

b)

String

c)

List

d)

Integer

4.

What is the result of this operation?

print(2 ** 3)

a)

6

b)

8

c)

9

d)

ERROR

5.

How do you start a comment in Python?

a)

//

b)

#

c)

/*

d)

<--

6.

What will the following code print?

a)

Hello, World! Hello, World!

b)

Hello, World! Hello, Alice!

c)

Hello, Alice! Hello, World!

d)

None of the above

7.

What is the output of this code snippet?

a)

apple

b)

banana

c)

cherry

d)

Error

8.

How do you handle exceptions in Python?

a)

Using try-except

b)

Using catch

c)

Using if-else

d)

Using finally

9.

What does the following list comprehension do?

a)

Creates a list of squares of numbers from 0 to 4

b)

Creates a list of numbers from 0 to 5

c)

Creates a list of numbers from 1 to 5

d)

Creates a list of numbers from 1 to 25

10.

What will the following code snippet output?

a)

[1, 2, 3]

b)

[1, 2, 3, 4]

c)

[1, 2]

d)

Error

11.

What is the purpose of the @staticmethod decorator?

a)

Define a method that does not require access to the instance or class

b)

Define a method that can only access class-level data

c)

Define a method that modifies static variables

d)

None of the above

12.

What will be the output of this code?

a)

[1] [1]

b)

[1, 1] [1, 1]

c)

[1] [1, 1]

d)

Error

13.

How can you create a Python generator?

a)

Using the yield keyword

b)

Using return inside a loop

c)

Using the @generator decorator

d)

Using next function only

14.

What will be the output of this code snippet?

a)

10

b)

15

c)

20

d)

Error

15.

How do you optimize a function for large datasets?

a)

Use recursion for efficiency

b)

Use generators to yield data incrementally

c)

Load all data into memory for faster access

d)

Use print statements to debug and optimize