wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python Programming Quiz

Total questions: 25

Worksheet time: 13mins

Name
Class
Date
1.

Which of these is not a core data type?

a)

Lists

b)

Dictionary

c)

Tuples

d)

Class

2.

What data type is the object below ?

D = [1, 23, ‘hello’, 1]

a)

Dictionary

b)

List

c)

Tuple

d)

Array

3.

What is the output of the following code :

print 9//2

a)

4.5

b)

4.0

c)

4

d)

Error

4.

What is the maximum possible length of an identifier?

a)

16

b)

32

c)

64

d)

None of these

5.

Who developed the Python language?

a)

Zim Den

b)

Guido van Rossum

c)

Niene Stom

d)

Wick van Rossum

6.

Which one of the following is the correct extension of the Python file?

a)

.python

b)

.p

c)

.py

d)

None of these

7.

What do we use to define a block of code in Python language?

a)

Key

b)

Brackets

c)

Indentation

d)

parenthesis

8.

Which of the following declarations is incorrect?

a)

_x = 2

b)

__x = 3

c)

__xyz__ = 5

d)

None of these

9.

Which of the following declarations is incorrect in python language?

a)

xyzp = 5,000,000

b)

x y z p = 5000 6000 7000 8000

c)

x,y,z,p = 5000, 6000, 7000, 8000

d)

x_y_z_p = 5,000,000

10.

Which of the following operators is the correct option for power(ab)?

a)

a ^ b

b)

a**b

c)

a ^ ^ b

d)

a ^ * b

11.

What will be the output of this statement?

>>>"a"+"bc"

a)

a+bc

b)

a bc

c)

abc

d)

a

12.

Which of the following is the correct statement?

z = {"x":0, "y":1}

a)

Dictionary z is created

b)

x and y are the keys of dictionary z

c)

0 and 1 are the values of dictionary z

d)

All of the above

13.

Which keyword is used for function?

a)

Fun

b)

define

c)

def

d)

function

14.

Which among these are the special operators in python

a)

Logical Operator

b)

Bitwise operator

c)

Membership operator

d)

Relational operator

15.
In python the ' STRING data type' can be defined as...?
a)
holds alphanumeric text
b)
hold whole numbers
c)
holds numbers with a decimal point
d)
holds either a true or false value
16.
What is the output from the following code?print ("hello world")
a)
Hello World
b)
hello world
c)
print hello world
17.

Which one is NOT a legal variable name?

a)

my_var

b)

my-var

c)

_myvar

d)

Myvar

18.

What is the correct syntax to output the type of a variable or object in Python?

a)

print(typeof(x))

b)

print(typeof x)

c)

print(typeOf(x))

d)

print(type(x))

19.

In Python, 'Hello', is the same as "Hello"

a)

True

b)

False

20.

What is a correct syntax to return the first character in a string?

a)

x = sub("Hello", 0, 1)

b)

x = "Hello"[0]

c)

x = "Hello".sub(0, 1)

21.
What will the output be from the following code?
print("3+4")
a)
7
b)
3+4
c)
34
d)
SyntaxError
22.
Why do we use variables in programming?
a)
edit data
b)
store data
c)
integer
d)
to look good
23.

Which of these is the correct code for creating a list of names?

a)

nameList = John, Harry, Mac, Donald, Colonel, Tony

b)

nameList = ("John", "Harry", "Mac", "Donald", "Colonel", "Tony")

c)

nameList = ["John", "Harry", "Mac", "Donald", "Colonel", "Tony"]

d)

nameList = [John, Harry, Mac, Donald, Colonel, Tony]

24.

Which of the following is the correct output of the call to below line of code?


print(list("hello"))

a)

['h', 'e', 'l', 'l', 'o']

b)

None of these

c)

[h,e,l,l,o]

d)

['h' 'e' 'l' 'l' 'o']

25.

Gjdk is not a good name for a variable, why?

a)

It starts with a capital letter.

b)

It does not contain any spaces.

c)

There are no vowels.

d)

It's meaningless.