55285A: Advanced Python Quiz Questions and Answers

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 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

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

Answer :
  • walk

Which method of a file object is used to close a file?

Answer :
  • close

Is it possible to link a Python program to code written in C?

Answer :
  • Yes; the C code can be in a form of a dynamically or a statically linked library.

What is the correct file extension for Python files?

Answer :
  • .py

Which of the following is an invalid statement?

Answer :
  • x y z = 1 2 3

How do you insert comments in Python code?

Answer :
  • #This is a comment