wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Basic of Programming - Quiz 02

Total questions: 15

Worksheet time: 15mins

Name
Class
Date
1.

Which of the following is invalid?

a)

_a = 1

b)

__a = 1

c)

__str__ = 1

d)

none of the mentioned

2.

Which of the following is an invalid variable?

a)

my_string_1

b)

1st_string

c)

foo

d)

_

3.

Which of the following is an invalid statement?

a)

abc = 1,000,000

b)

a b c = 1000 2000 3000

c)

a,b,c = 1000, 2000, 3000

d)

a_b_c = 1,000,000

4.

What is the answer to this expression, 22 % 3 is?

a)

7

b)

1

c)

0

d)

5

5.

Mathematical operations can be performed on a string.

a)

True

b)

False

6.

Which of these in not a core data type?

a)

Lists

b)

Dictionary

c)

Tuples

d)

Class

7.

What will be the output of the following Python code?

a)

he

b)

lo

c)

olleh

d)

hello

8.

What data type is the object below?

L = [1, 23, 'hello', 1]

a)

list

b)

dictionary

c)

array

d)

tuple

9.

In order to store values in terms of key and value we use what core data type.

a)

list

b)

tuple

c)

class

d)

dictionary

10.

What is the average value of the following Python code snippet?

a)

85.0

b)

85.1

c)

95.0

d)

95.1

11.

Select all options that print.

hello-how-are-you

a)

print(‘hello’, ‘how’, ‘are’, ‘you’)

b)

print(‘hello’, ‘how’, ‘are’, ‘you’ + ‘-‘ * 4)

c)

print(‘hello-‘ + ‘how-are-you’)

d)

print(‘hello’ + ‘-‘ + ‘how’ + ‘-‘ + ‘are’ + ‘you’)

12.

What will be the output of the following Python code?

a)

0 1 2 3 0

b)

0 1 2 0

c)

0 1 2

d)

error

13.

What will be the output of the following Python code?

a)

0 1 2

b)

{0, 1, 2} {0, 1, 2} {0, 1, 2}

c)

error

d)

none of the mentioned

14.

What will be the output of the following Python code?

a)

0

b)

no output

c)

error

d)

none of the mentioned

15.

What will be the output of the following Python statement?

a)

a

b)

bc

c)

bca

d)

abc