wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python if s

Total questions: 10

Worksheet time: 6mins

Name
Class
Date
1.

Python was invented by

a)

Dennis Ritchie

b)

Guido Van Rossum

c)

Abel

d)

Marro

2.

the output of the following code is

# program for addition of 2 numbers

a = 10

b = 3

c = a + b

print("the sum is ", c)

a)

7

b)

10

c)

13

d)

3

3.

output of the following question is:

#program for text addition

# input() method

f_name= "hello"

l_name ="world"

print( f_name + l_name)

a)

helloworld

b)

hello world

c)

error

d)

f_name+l_name

4.

output of following code:

# \n in program

print("welcome\nto Python")

print("*********\n*********")

print("8th grade\nstudents\nare good")

a)

error

b)

welcome to Python 8th grade students are good

c)

welcometoPython8thgradestudentsaregood

d)

welcome

to Python

*********

*********

8th grade

students

are good

5.

what will be printed for the value 8 for num

# program to check even or odd

num = (int)(input("enter any number"))

if num%2 == 0:

print("the number is even")

else :

print("the number is odd")

a)

even

b)

the number is even

c)

the number is odd

d)

None

6.

range(5) gives the following list of values

a)

1, 2, 3, 4, 5

b)

1, 2, 3, 4

c)

0, 1, 2, 3, 4

d)

0, 1, 2, 3, 4, 5

7.

what will be printed for:

for x in range (1, 7):

print(x)

a)

7

b)

1, 2, 3, 4, 5, 6, 7

c)

1, 7

d)

1, 2, 3, 4, 5, 6

8.

Loop is an iterative structure.

(a)   is an example of loops in Python

9.

Python has how many keywords

a)

12

b)

32

c)

33

d)

45

10.

Is python related to snakes?

a)

yes

b)

no

c)

may be