Logo

Python Questions Set 5:

Quiz Mode

>>> x = y = z = 2
>>> x, y, x

1
2
3
4

Solution:

What will be the output of the following Python code?

print('''
\tfoo'''.lstrip())

1
2
3
4

Solution:

Predict the output of the following code:


print("Yes\"Yes\hello\"")

1
2
3
4

Solution:

What will be the output of the given code?


import sys


sys.stdout.write("hello world")

1
2
3
4

Solution:

What will be the output of the following Python code?

x = "abcdef"
i = "a"
while i in x[:-1]:
print(i, end=" ")

1
2
3
4

Solution:

When is the else block of a try-except-else statement executed?

1
2
3
4

Solution:

Suppose list1 is [3, 4, 5, 20, 5, 25, 1, 3], what is list1 after list1.pop(1)? 

1
2
3
4

Solution:

 

What will be the output of the following Python code?


print(math.isinf(float('-inf')))

1
2
3
4

Solution:

How do you create a private variable in a Python class?

1
2
3
4

Solution:

print "how old are you? (in years)"

age = raw_input()

print "how tall are you? (in ft & inches)"

height = raw_input()

print "you are %r years old and %r tall" % (age,height)

#21 years and 5'6" are the input from the users




1
2
3
4

Solution: