Online Exam Quiz

questionQuestion  1 to 30

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

  • 3
  • 3.3
  • 4
  • 3
Mark for review

What is the correct syntax to output "Hello World" in Python?

  • echo "Hello World"
  • p("Hello World")
  • print("Hello World")
  • printf("Hello World")
Mark for review

How do you check if a key exists in a dictionary?

  • if key in dict:
  • if key exists dict:
  • if key in dict.keys():
  • Both if key in dict: and if key in dict.keys():
Mark for review

What is the data type of the following: 3.14?

  • int
  • float
  • str
  • bool
Mark for review

How do you create a new file in Python?

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

Which of the following is a mutable data type in Python?

  • str
  • tuple
  • list
  • int
Mark for review

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

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

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

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

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

  • 6
  • 8
  • 9
  • 12
Mark for review

Which method can be used to return a string in upper case letters?

  • upperCase()
  • upper()
  • uppercase()
  • toUpperCase()
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 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

What is the correct file extension for Python files?

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

How can you create a number object in Python?

  • int()
  • float()
  • complex()
  • All of the above
Mark for review

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

  • len()
  • length()
  • size()
  • count()
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

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

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

Which method can be used to remove elements from a list?

  • delete()
  • remove()
  • del()
  • Both remove() and del()
Mark for review

Which of the following is not a keyword in Python?

  • TRUE
  • FALSE
  • None
  • maybe
Mark for review

Which of the following is used to iterate over a sequence in Python?

  • for loop
  • while loop
  • do-while loop
  • Both for and while loop
Mark for review

How can you copy a list in Python?

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

How do you define a lambda function?

  • lambda x, y: x + y
  • def lambda(x, y): x + y
  • lambda (x, y): x + y
  • def lambda x, y: x + y
Mark for review

How do you check if a variable is equal to a value in Python?

  • if x equals 5
  • if x = 5
  • if x == 5
  • if x == '5'
Mark for review

What is the output of len("Hello")?

  • 4
  • 5
  • 6
  • 7
Mark for review

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

  • max()
  • highest()
  • top()
  • greatest()
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

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

How do you create a set in Python?

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

Which of the following is a tuple?

  • {1, 2, 3}
  • [1, 2, 3]
  • (1, 2, 3)
  • {1: 2, 3: 4}
Mark for review

How do you comment multiple lines in Python?

  • //
  • /* */
  • """ """
  • <!-- -->
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