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

How do you insert an element at a specific index in a list in Python?

  • list.add(1, 'x')
  • list.insert(1, 'x')
  • list.append(1, 'x')
  • list.include(1, 'x')
Mark for review

Which of the following is not a keyword in Python?

  • TRUE
  • FALSE
  • None
  • maybe
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 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 is the output of the following code: print("Python".lower())?

  • python
  • Python
  • PYTHON
  • pythoN
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

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

  • TRUE
  • FALSE
  • None
  • Error
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 output of the following code: print(10 // 3)?

  • 3
  • 3.3
  • 4
  • 3
Mark for review

Which method is used to add an element to a set in Python?

  • add()
  • append()
  • insert()
  • include()
Mark for review

How do you comment multiple lines in Python?

  • //
  • /* */
  • """ """
  • <!-- -->
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 keyword is used to create a function in Python?

  • function
  • define
  • func
  • def
Mark for review

Which operator is used to multiply numbers in Python?

  • #
  • *
  • %
  • @
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

What is the data type of the following: 3.14?

  • int
  • float
  • str
  • bool
Mark for review

What is the output of 5 + 3 * 2?

  • 16
  • 11
  • 13
  • 10
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 create a new file in Python?

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

Which method can be used to remove any whitespace from both the beginning and the end of a string?

  • ptrim()
  • trim()
  • strip()
  • len()
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 dictionary in Python?

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

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

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

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

  • if
  • when
  • while
  • switch
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

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

  • 4
  • 5
  • 6
  • 7
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 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

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