Online Exam Quiz

questionQuestion  1 to 30

Which of the following is used to define a block of code in Python?

  • Curly braces {}
  • Parentheses ()
  • Indentation
  • Square brackets []
Mark for review

How can you copy a list in Python?

  • list.copy()
  • list[:]
  • Both list.copy() and list[:]
  • copy(list)
Mark for review

What is the output of the following code: print(bool(""))?

  • TRUE
  • FALSE
  • None
  • Error
Mark for review

Which of the following is a built-in function in Python?

  • val()
  • print()
  • input()
  • Both print() and input()
Mark for review

What is the correct way to open a file for reading in Python?

  • open("filename", "r")
  • open("filename", "w")
  • open("filename", "rw")
  • open.file("filename", "r")
Mark for review

What does the pop() method do in Python?

  • Removes the first element of a list
  • Removes the last element of a list
  • Adds an element to the end of a list
  • Adds an element to the beginning of a list
Mark for review

How do you create a variable with the floating number 2.8?

  • x = 2.8
  • x = float(2.8)
  • Both the above
  • None of the above
Mark for review

What is the output of the following code: print("Python".lower())?

  • python
  • Python
  • PYTHON
  • pythoN
Mark for review

How do you get the length of a tuple in Python?

  • len()
  • length()
  • size()
  • count()
Mark for review

Which of the following is not a keyword in Python?

  • TRUE
  • FALSE
  • None
  • maybe
Mark for review

Which keyword is used to begin a conditional statement in Python?

  • if
  • when
  • while
  • switch
Mark for review

What is the correct way to handle multiple exceptions in a single except block?

  • except (TypeError, ValueError):
  • except [TypeError, ValueError]:
  • except {TypeError, ValueError}:
  • except <TypeError, ValueError>:
Mark for review

Which method is used to find the highest value in a list?

  • max()
  • highest()
  • top()
  • greatest()
Mark for review

What is the output of the following code: print(10 // 3)?

  • 3
  • 3.3
  • 4
  • 3
Mark for review

What does the term "PEP" stand for in Python?

  • Python Enhancement Proposal
  • Python Enterprise Proposal
  • Python Extended Proposal
  • Python Efficient Proposal
Mark for review

How do you start a loop in Python?

  • for i to range
  • for i in range
  • for i = 1 to 10
  • for i in 1..10
Mark for review

Which operator is used to multiply numbers in Python?

  • #
  • *
  • %
  • @
Mark for review

What does the term "immutable" mean in Python?

  • The value cannot be changed
  • The value can be changed
  • The variable is constant
  • The variable is flexible
Mark for review

What is the correct file extension for Python files?

  • .pt
  • .pyt
  • .pyth
  • .py
Mark for review

How do you create a dictionary in Python?

  • {1, 2, 3}
  • [1, 2, 3]
  • {1: "one", 2: "two"}
  • (1, 2, 3)
Mark for review

Which function is used to get user input in Python 3.x?

  • raw_input()
  • input()
  • scan()
  • scanf()
Mark for review

What is the output of the following code: print(3 * 'A')?

  • AAA
  • A A A
  • 'AAA'
  • 'A A A'
Mark for review

What is the output of the following code: print(type([]))?

  • <class 'list'>
  • <class 'dict'>
  • <class 'tuple'>
  • <class 'set'>
Mark for review

What is the correct way to create a list in Python?

  • list = {1, 2, 3}
  • list = [1, 2, 3]
  • list = (1, 2, 3)
  • list = 1, 2, 3
Mark for review

What is the output of 5 + 3 * 2?

  • 16
  • 11
  • 13
  • 10
Mark for review

What is the output of print(2 ** 3)?

  • 6
  • 8
  • 9
  • 12
Mark for review

How do you insert COMMENTS in Python code?

  • //This is a comment
  • /This is a comment/
  • #This is a comment
  • <!--This is a comment-->
Mark for review

What is the correct way to handle exceptions in Python?

  • try: except:
  • try: catch:
  • try: except: finally:
  • try: catch: finally:
Mark for review

Which of these is the definition of a Python function named "func" that takes no parameters?

  • function func()
  • def func():
  • func()
  • def func:
Mark for review

Which keyword is used to create a function in Python?

  • function
  • define
  • func
  • def
Mark for review

blinkerOnline

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • Answered
  • Not Answered
  • Marked for Review