Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python Phase 1

Total questions: 30

Worksheet time: 3600secs

Name
Class
Date
1.

Which of the following variable names is invalid in Python?

a)

data_value

b)

3data

c)

_data

d)

DataValue

2.

Which of the following is NOT a keyword in Python?

a)
  • pass

b)

break

c)

def

d)
  • print

3.
  1. What is the data type of the following variable?


a)

<class 'int'>, <class 'int'>

b)
  • <class 'str'>, <class 'int'>

c)
  • <class 'str'>, <class 'str'>

d)
  • <class 'int'>, <class 'str'>

4.

What will be the output of the following code snippet?

a)

3, 3

b)

3, 3.33

c)
  1. 3, 3.0

d)

Error

5.

What is the result of the following expression?

a)

7

b)

8

c)

5

d)

6

6.
  1. What will be the result of the following operation?

a)

2

b)

3

c)

4

d)

1

7.

What will happen when the following code is executed?
print("Hello)

a)

Hello will be printed.

b)
  • An error will occur.

c)

 Nothing will be printed.

d)
  • It will print None.

8.
  1. Identify the error in the following code:

a)

 Missing # for a comment

b)

The variable x is not defined

c)

Missing colon : after the if condition

d)
  • Incorrect indentation after if

9.
  1. What will be printed by the following code snippet?

a)
  • b is greater than 15

b)
  • a is greater than b

c)
  • b is not greater than 15

d)
  • No output

10.
  1. What is the output of the following code?
    lst = [1, 2, 3]

print(type(lst))


a)

<class 'tuple'>

b)

<class 'list'>

c)

<class 'set'>

d)

<class 'dict'>

11.

What will be the output of the following code?

a)

Positive

b)

Zero

c)
  • Negative

d)

Error

12.
  1. Which of the following is the correct way to write a multi-line comment in Python?

a)

# This is a multi-line comment

b)

// This is a multi-line comment

c)

/* This is a multi-line comment */

d)
  • """ This is a multi-line comment """

13.
  1. Which of the following is not a valid comment syntax in Python?

a)
  • # This is a single-line comment

b)
  • ''' This is a multi-line comment '''

c)
  • " This is a comment "

d)
  • """ This is also a valid multi-line comment """

14.
  1. Which of the following is not a valid Python data type?

a)
  1. int

b)

float

c)
  1. long

d)
  1. dict

15.
  1. What will be the value of x after the following code executes?
    x = 2 *3 ** 2

a)

18

b)

12

c)

36

d)

9

16.
  1. What will be the output of the following code?
    print(type(10.5))

a)
  • <class 'int'>

b)
  • <class 'float'>

c)
  • <class 'str'>

d)

<class 'double'>

17.

What will be the output of the following code?

a)

3.14

b)

3

c)

4

d)

Error

18.
  1. Which of the following statements is true about Python variable naming conventions?

a)

Variables can start with a digit.

b)
  • Variables can start with an underscore _.

c)

Variables can contain spaces.

d)
  • Variables can contain special characters like @ or %.

19.

Which of the following statements will execute only if both conditions are True?

a)

if a or b:

b)

if a and b:

c)

if not a:

d)

if a + b:

20.

What will be the output of the following code?

a)
  • [1, 2, 3]

b)
  • [1, 2, 3, 4]

c)

None

d)
  • Error

21.

What will be the output of the following code?

a)

[10, 20, 25, 30, 40]

b)
  • [10, 25, 20, 30, 40]

c)

[25, 10, 20, 30, 40]

d)
  • [10, 20, 30, 25, 40]

22.

What will be the output of the following code?

a)

{1, 2, 3, 4, 3}

b)
  • {1, 2, 3}

c)

{1, 2, 3, 4}

d)

{3, 4, 1, 2, 3}

23.

What will be the output of the following code?

a)

(1, 5, 3)

b)

(1, 2, 3)

c)

Error

d)

[1, 5, 3]

24.

What will be the output of the following code?

a)
  • {1, 2, 3, 4, 5}

b)
  • {3}

c)

{1, 2, 4, 5}

d)

Error

25.
  1. Which of the following operations is NOT valid for tuples?

a)
  • tup[1]

b)

len(tup)

c)
  • tup[1:3]

d)
  • tup.append(4)

26.

What will be the result of the following code?

a)
  • {'x': 10, 'y': 20}

b)

{'x': 30, 'y': 20}

c)
  • {'x': 40, 'y': 20}

d)
  • {'x': 0, 'y': 20}

27.

What will be the output of the following code?

a)

"Hello Python"

b)

"Python World"

c)

"Hello World"

d)

Error

28.

What will be the output of the following code?

a)

"Pyth"

b)

"ytho"

c)

"yth"

d)

"ython"

29.

What will be the result of the following code?

a)

"Data"

b)

"data"

c)

Error

d)

"Ddata"

30.
  1. What will be the output of the following code?

a)

"Python Programming"

b)

" Python Programming"

c)
  • "Python Programming "

d)

"PythonProgramming "