Advanced Python Programming Quiz Questions and Answers

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

Answer :
  • Method

What will be the output for the following Program? #!/usr/bin/python3 i = 3 while True: if i%5 == 0: break print(i) i += 2

Answer :
  • 3

Which one of the following is the equality test operator in Python?

Answer :
  • ==

Which Data Type in Python maintains data in the form of Key-Value Pairs?

Answer :
  • Dictionary

What will be the result of : print(2^6)

Answer :
  • 4

What will be the result of : x = 100 print(~x)

Answer :
  • -101

What will be the result for the following code? class mytest: def __init__(self,a): self.a=a def display(self): print(self.a) obj=mytest() obj.display()

Answer :
  • Error message

What will happen if we open a file for writing and the file does not exist?

Answer :
  • The file will be created for writing

Which Method is used to recursively list the contents of a directory and all its subdirectories?

Answer :
  • walk

Which one of the following statements will assign the value of 100 to a and value of 200 to b?

Answer :
  • a,b = 100,200