Logo

Python Questions Set 33:

Quiz Mode

Which of the following round() function calls will run without errors?

1
2
3
4

Solution:

What is the output of the following Python code?

print('xyyzxxyxyy'.lstrip('xyy'))

1
2
3
4

Solution:

 

What will be the output of the following Python code?

>>> str1 = 'hello'

>>> str2 = ','

>>> str3 = 'world'

>>> str1[-1:]

1
2
3
4

Solution:

 

What will be the output of the following Python code?

import datetime
d=datetime.date(2017,06,18)
print(d)

1
2
3
4

Solution:

What is the output of the following code?


x = 8

y = 8.0000

if x == y:

    print("If block")

else:

    print("Else block")

1
2
3

Solution:

What will be the output of the following Python code?


d = {0: 'a', 1: 'b', 2: 'c'}
for x in d.values():
   print(x)

1
2
3
4

Solution:

 

What will be the output of the following Python code snippet?

print('abcd'.translate({'a': '1', 'b': '2', 'c': '3', 'd': '4'}))

1
2
3
4

Solution:

What will the below python code print:


name = "Rishi"

age = 29

print("Hi " + name + ", " + age + " years old")

1
2
3
4

Solution:

What is the correct syntax to generate random integers between 1 and 10?

1
2
3
4

Solution:

Find the output of the following code:

a = 100
b = 0
try:
print(a / b)
except:
print("Zero division error")
print("success")

1
2
3
4

Solution: