wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Python Training Day-2 Quiz-2

Total questions: 10

Worksheet time: 5mins

Name
Class
Date
1.

What will be the output of the following Python code?

>>>str="hello"

>>>str[:2]

>>>

a)

he

b)

lo

c)

olleh

d)

hello

2.

What error occurs when you execute the following Python code snippet?

apple = mango

a)

SyntaxError

b)

NameError

c)

ValueError

d)

TypeError

3.

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

4.

The following is displayed by a print function call. Select all of the function calls that result in this output.

tom

dick

harry

a)

print('''tom

\ndick

\nharry''')

b)

print(”’tomdickharry”’)

c)

print(‘tom\ndick\nharry’)

d)

print('tom

dick

harry')

5.

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’)

6.

Which statement is correct?

a)

List is immutable && Tuple is mutable

b)

List is mutable && Tuple is immutable

c)

List & Tuple are mutable

d)

List & Tuple are immutable

7.

How to get last element of list in python? Suppose we have list with name arr, contains 5 elements.

a)

arr[0]

b)

arr[5]

c)

arr[last]

d)

arr[-1]

8.

Which is the correct operator for power(xy)?

a)

X^y

b)

X**y

c)

X^^y

d)

None of the mentioned

9.

What will be the output of the following code?

arr = [1,2,3,4,5,6]

print(a[::2])

a)

[1,3,5]

b)

[2,4,6]

c)

[1,2]

d)

[5,6]

10.

Which of these about a dictionary is false?

a)

The values of a dictionary can be accessed using keys

b)

The keys of a dictionary can be accessed using values

c)

Dictionaries aren't ordered

d)

Dictionaries are mutable