Logo

Python Questions Set 138:

Quiz Mode

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

1
2
3
4

Solution:

 

What will be the output of the following Python code?

>>>str="hello"

>>>str[:2]

>>>

1
2
3
4

Solution:

What is pass in Python?

1
2
3
4

Solution:

Given the following Python code:

s = 'apple'

x = s.find('p')

y = s.find('f')

z = s.find(' ')

print(x + y + z)

1
2
3
4

Solution:

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

1
2

Solution:

Is the following Python code valid?

>>> a=2,3,4,5
>>> a

1
2
3
4

Solution:

What will be the output of the program?

from sys import*


name = argv

variable = raw_input("hello world")

print name


1
2
3
4

Solution:

What will be the output of the following Python code?

i = 5
while True:
   if i%0O9 == 0:
       break
   print(i)
   i += 1

1
2
3
4

Solution:

 Which of the following is the use of id() function in python?
 

1
2
3
4

Solution:

Find the output of the following code:

class StudentFail(Exception): def __init__(self, msg): super().__init__(msg) class Student: def __init__(self, marks): self.marks = marks def pass_fail(self): if self.marks < 35: raise StudentFail('Student is Fail') else: print("Student is passed") s1 = Student(35) s1.pass_fail()

1
2
3
4

Solution: