wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Python Programming

Total questions: 25

Worksheet time: 12mins

Name
Class
Date
1.

Write the output of the following code:

x=2

x=5

x=x+x

print(x)

a)

7

b)

10

c)

4

d)

Error

2.

Write the output of the following code :

x=2

y=3

x+y+5

print(x+y)

a)

8

b)

6

c)

10

d)

5

3.

What is a keyword?

a)

Reserved Word

b)

Predefined Word

c)

Keywords are part of the syntax and they cannot be used as an identifier.

d)

All of them

4.

Which statement will display square of number (n)

a)

print(n * n)

b)

print(math.pow(n,2)) # math module is already imported

c)

All of the above

d)

Only First

5.

Select the reserved keyword in python-

a)

else

b)

raise

c)

import

d)

All of them

6.

What will be the output of this string operation s[2:5] , if s="hello world" -

a)

lo

b)

llo

c)

llow

d)

ell

7.

Which of the following character is used to give single-line comments in Python?

a)

//

b)

#

c)

!

d)

/*

8.

What will be the output?

name = 'Python'

print (type(name))

a)

char

b)

'Python'

c)

str

d)

Error

9.

What will be the output?

d = 10 < 11

print (d)

a)

10

b)

11

c)

True

d)

False

10.

Identify the arithmetic operator which is used to calculate exponential.

a)

*

b)

%

c)

!

d)

**

11.

What will be the output?

str1 = "Deep Learning"

print (len(str1))

a)

11

b)

12

c)

13

d)

Out of Range Error

12.

What will be the output?

a = 25

b = 4

print (a%b)

a)

1

b)

6

c)

6.2

d)

1.5

13.

What will be the output ?

print (type(5 // 2))

a)

int

b)

float

c)

2

d)

2.5

14.
What is Python really?
a)
Python is an interpreted language.
b)
visual basic
c)
a snake 
d)
a form of font for writing 
15.
what are the advantages of python?
a)
free and open source 
b)
can do the work for you 
c)
easy 
16.
If you want more than one option for your code, what do you use (after if)?
a)
elif
b)
else
c)
ifif
17.

A string

a)

carries out an action

b)

the elements of a command

c)

a collection of characters

d)

how elements in a commad are arranged

18.

1. He is a Dutch Programmer known as the creator of Python?

a)

a. Rasmus Lerdorf

b)

b. James Gosling

c)

c. Guido van Rossum

d)

d. Niklaus Wirth

19.

2. What does IDE mean?

a)

a. Internet Detection Entertainment

b)

b. Integrated Development Environment

c)

c. Instantaneous Differentiation Equipment

d)

d. Intermediate Development Element

20.

3. Which of the following is not an IDE for Python?

a)

a. XML

b)

b. Pycharm

c)

c. Visual Studio Code

d)

d. Thonny

21.

5. It is the process of joining two or more strings.

a)

a. Addition

b)

b. Concatenation

c)

c. Integration

d)

d. Differentiation

22.

6. What does % math operator do?

a)

a. To get the remainder of the two numbers.

b)

b. To get the square root of two numbers.

c)

c. To get the percentage from those two numbers.

d)

d. To get the quotient of the two numbers.

23.

7. What does == mean?

a)

a. Assignment operator

b)

b. Answer operator

c)

c. Equality operator

d)

d. Mathematical operator

24.

8. What symbol is used to denote "not equal"?

a)

a. *=

b)

b. @=

c)

c. ?=

d)

d. !=

25.

for i in 100 :

print ( i )

a)

Syntax error

b)

prints numbers 0 to 100

c)

prints numbers 1 to 100

d)

prints numbers 0 to 99

e)

prints numbers 1 to 99