Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Play with Python

Total questions: 52

Worksheet time: 1hrs 25mins

Name
Class
Date
1.

What is the result of the expression if x=15 and y=12:

a)

b1101

b)

0b1101

c)

12

d)

15

2.

Which of the following represents the bitwise XOR operator?

a)

&

b)

^

c)

|

d)

!

3.

What is the value of the following expression?


2+4.00, 2**4.0

a)

(6.0, 16.0)

b)

(6.00, 16.00)

c)

(6, 16)

d)

(6.00, 16.0)

4.

Which of the following will run without errors ?

a)

round(45.8)

b)

round(6352.898,2,5)

c)

round()

d)

round(7463.123,2,1)

5.

What is the reason you think that cost the test series vs kiwis?

a)

VK Captaincy

b)

Boom Boom current form

c)

Regular Opener's Injury

d)

Collective Failure

6.

What dataype is the object below ? L = [1, 23, ‘hello’, 1].

a)

List

b)

Sets

c)

dictionary

d)

Tuple

7.

What is the maximum possible length of an identifier?

a)

31 characters

b)

63 characters

c)

79 characters

d)

None of the above

8.

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

9.

How is our python class ?

a)

Except subject matter, we are learning everything

b)

It's a fair balance between both inside and outside subject matter.

c)

Feel like bunking always

d)

Wait....are you teaching python for us ????

10.

What is the output when following code is executed ?

print r"\nhello"

The output is

a)

a new line and hello

b)

\nhello

c)

the letter r and then hello

d)

Error

11.

What is the output of the following code ?


example = "snow world"

example[3] = 's'

print example

a)

snow

b)

snow world

c)

Error

d)

snos world

12.

What is the output of “hello”+1+2+3 ?

a)

hello123

b)

hello

c)

Error

d)

hello6

13.

What is the output of the following?


print('The sum of {0} and {1} is {2}'.format(2, 10, 12))

a)

The sum of 2 and 10 is 12

b)

Error

c)

The sum of 0 and 1 is 2

d)

None above

14.

How many keyword arguments can be passed to a function in a single function call?

a)

zero

b)

one

c)

zero or more

d)

one or more

15.

What is the output of the code shown below?


def f1():

x=100

print(x)

x=+1

f1()

a)

Error

b)

100`

c)

101

d)

99

16.

On assigning a value to a variable inside a function, it automatically becomes a global variable. State whether true or false.

a)

True

b)

False

c)

Error

d)

None mentioned

17.

Which of these is false about recursion?

a)

Recursive function can be replaced by a non-recursive function

b)

Recursive functions usually take more memory space than non-recursive function

c)

Recursive functions run faster than non-recursive function

d)

Recursion makes programs easier to understand

18.

One change that u want me to make up ?

a)

Better give more marks, irrespective of what we write

b)

Try to Speak more in telugu rather english

c)

Please stop all additional stories and deliver only python

d)

Be as you are now

19.

What is the output of the code shown below?


l1=[1, 2, 3, [4]]

l2=list(l1)

id(l1)==id(l2)

a)

True

b)

False

c)

Error

d)

Address of l1

20.

Which of the following statements is used to create an empty set?

a)

{ }

b)

set()

c)

[ ]

d)

( )

21.

What is the output of the line of code shown below, if s=set([1, 2, 3]), s1= {1, 2, 3}?

s1.issubset(s1)

a)

True

b)

Error

c)

No output

d)

False

22.

What will be the output?


d = {"john":40, "peter":45}

d["john"]

a)

40

b)

45

c)

"john"

d)

"peter"

23.

What is the output of the following piece of code when executed in Python shell?


a=("Check")*3

a

a)

(‘Check’,’Check’,’Check’)

b)

* Operator not valid for tuples

c)

(‘CheckCheckCheck’)

d)

Syntax error

24.

Is the following piece of code valid?


a=2,3,4,5

a

a)

Yes, 2 is printed

b)

Yes, [2,3,4,5] is printed

c)

No, too many values to unpack

d)

Yes, (2,3,4,5) is printed

25.

What is the output of the following?


i = 2

while True:

if i%3 == 0:

break

print(i)

i += 2

a)

2 4 6 8 10 …

b)

2 4

c)

2 3

d)

error

26.

I'm giving you another chance to change your dept. Which one do you choose ?

a)

In all birth,ECE only.

b)

May be I'll go with CSE and join with u

c)

This time why not Civil / Mech

d)

I will run as fast as I can to escape from engineering itself

27.

What is the output of the following?


x = "abcdef"

i = "a"

while i in x:

x = x[:-1]

print(i, end = " ")

a)

i i i i i i

b)

a a a a a a

c)

a a a a a

d)

none of the mentioned

28.

What is the output of the following?


x = "abcdef"

i = "i"

while i in x:

print(i, end=" ")

a)

no output

b)

i i i i i i …

c)

a b c d e f

d)

abcdef

29.

What is the output of the following?


d = {0: 'a', 1: 'b', 2: 'c'}

for x in d.values():

print(x)

a)

0 1 2

b)

a b c

c)

0 a 1 b 2 c

d)

none of the mentioned

30.

What is the output of the following?


string = "my name is x"

for i in string.split():

print (i, end=", ")

a)

m, y, , n, a, m, e, , i, s, , x,

b)

m, y, , n, a, m, e, , i, s, , x

c)

my, name, is, x

d)

error

31.

Whom do u think will clinch IPL2020 trophy?

a)

MI

b)

CSK

c)

SRH

d)

RCB

e)

Others

32.

What is the output of the following?


a = [0, 1, 2, 3]

for a[0] in a:

print(a[0])

a)

0 1 2 3

b)

0 1 2 2

c)

3 3 3 3

d)

error

33.

What is the output of the following snippet of code?


total={}

def insert(items):

if items in total:

total[items] += 1

else:

total[items] = 1

insert('Apple')

insert('Ball')

insert('Apple')

print (len(total))

a)

3

b)

1

c)

2

d)

0

34.

What is the output of the following code?


a={}

a[2]=1

a[1]=[2,3,4]

print(a[1][1])

a)

[2,3,4]

b)

3

c)

2

d)

An exception is thrown

35.

What is called when a function is defined inside a class?

a)

Module

b)

Class

c)

Another function

d)

Method

36.

What is the output of below program?


def f(x, y, z): return x + y + z

f(2, 30, 400)

a)

432

b)

24000

c)

430

d)

No output

37.

What is the output of the following piece of code?


def a(b):

b = b + [5]

c = [1, 2, 3, 4]

a(c)

print(len(c))

a)

4

b)

5

c)

1

d)

An exception is thrown

38.

What is the output of the code shown below?


'The {} side {1} {2}'.format('bright', 'of', 'life')

a)

Error

b)

‘The bright side of life’

c)

‘The {bright} side {of} {life}’

d)

No output

39.

Do u really want me to come again in upcoming semesters ?

a)

What the hell, no wayyyyyyy

b)

If possible, yes please

c)

If your'e coming again, i'm discontinuing from vardhaman for sure

d)

It doesn't bother me whether u come or not, who cares ?

40.

What is the output for −

'you are doing well' [2:999]

a)

'you are doing well'

b)

' '

c)

Index error

d)

'u are doing well'

41.

a = 0

while a<10:

… print(''you are learning python'')

… pass

a)

9

b)

10

c)

11

d)

Infinity

42.

What is output for − min(''hello world'')

a)

e

b)

a blank space character

c)

w

d)

None of the above

43.

Suppose we are given with two sets(s1&s2) then what is the output of the code −

S1 + S2

a)

Adds the elements of the both the sets.

b)

Removes the repeating elements and adds both the sets.

c)

It is an illegal command.

d)

Output will be stored in S1.

44.

Output:

i = 1

while True:

if i%3 == 0:

break

print(i)

i + = 1

a)

1 2

b)

1 2 3

c)

error

d)

none

45.

What will be the output of the following Python code?

i = 1

while True:

if i%0O7 == 0:

break

print(i)

i += 1

a)

1 2 3 4 5 6

b)

1 2 3 4 5 6 7

c)

Error

d)

1 2 3 4 5 6 1 2 3 4 5 6

46.

What will be the output of the following Python code?

i = 5

while True:

if i%0O11 == 0:

break

print(i)

i += 1

a)

5 6 7 8 9 10

b)

5 6 7 8

c)

5 6

d)

error

47.

7. What will be the output of the following Python code?

i = 1

while True:

if i%2 == 0:

break

print(i)

i += 2

a)

1

b)

1 2

c)

1 2 3 4 5 6 …

d)

1 3 5 7 9 11 …

48.

What will be the output of the following Python code?

i = 2

while True:

if i%3 == 0:

break

print(i)

i += 2

a)

2 4 6 8 10 …

b)

2 4

c)

2 3

d)

error

49.

What will be the output of the following Python code?

i = 1

while False:

if i%2 == 0:

break

print(i)

i += 2

a)

1

b)

1 3 5 7 …

c)

1 2 3 4 …

d)

none

50.

What will be the output of the following Python code?

True = False

while True:

print(True)

break

a)

True

b)

False

c)

Error

d)

True = False

51.

How you answered all the questions?

a)

Genuinely

b)

Inky...pinky....ponky.....

c)

A friend in need is a friend indeed

d)

Based on my lucky number

52.

On the whole, How is this quiz assignment ?

a)

You saved us from writing..just for that its good

b)

Bit interesting..we ll stick to this

c)

Enough of this sir, Can I get some A4 sheets ???

d)

A good time pass thts it