wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python basic 2

Total questions: 15

Worksheet time: 8mins

Name
Class
Date
1.

Which is an invalid variable name in python

a)

a

b)

mark

c)

else

d)

x

e)

none of the above

2.

In Precedence of operators which has the lowest precedence

a)

Logical Not

b)

Addition

c)

Exponentiation

d)

==

e)

=

3.

A variable defined inside a function which is not available outside the function is known as

a)

Fariable

b)

variable

c)

local variable

d)

global variable

e)

none of the above

4.

>>> i = "Indian"

>>> i[2:]

displays

a)

In

b)

Ind

c)

dian

d)

india

5.

Extracting a part of string from original is called

a)

cutting

b)

fitting

c)

hitting

d)

slicing

e)

extracting

6.

Which is a comment entry in python

a)

*this is a comment

b)

//this is a comment//

c)

<this is a comment>

d)

#this is a comment

e)

None of the above

7.

Which of the following is a valid List

a)

x=[2,3,4,5]

b)

x=(2,3,4,5)

c)

x=["a","b",1,2,3.4,2+4j]

d)

x="1,2,2,3,5"

e)

None of the above

8.

x=0.23400004, the command to display 0.23 is

a)

print "%0.2d"%x

b)

print "%0.2f"%x

c)

print "%0.2f"x

d)

print x "0.2f"

e)

None of the above

9.

List is mutable.

a)

True

b)

False

10.

Find the mistake in the following code segment

import math

x=x+30

print sin(x)

a)

import math.py

b)

x=x+30, value of x not initialised

c)

print sin(x), should use math.sin(x)

d)

No error all fine

11.

An unordered collection of distinct/unique elements is called

a)

string

b)

list

c)

set

d)

variable

12.

The command range(5) creates

a)

a list [0,1,2,3,4]

b)

a list [0,1,2,3,4,5]

c)

a set (0,1,2,3,4)

d)

a set (0,1,2,3,4,5)

e)

gives error

13.

tuple and frozenset are

a)

mutable

b)

immutable

c)

variable names

d)

none of the above

14.

Which are valid dictionary command

a)

x=['a':1,'b':2,'c':3]

b)

x={'a':1,'b':2,'c':3}

c)

lst=[('a',1),('b',2),('c',3)]

x=dict(lst)

d)

None of the above

15.

The instruction to skip few lines of a loop in python

a)

skip

b)

break

c)

continue

d)

exit()

e)

None of the above