Online Exam Quiz

questionQuestion  1 to 30

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

What is the correct syntax to create a class in Python?

  • class MyClass:
  • class MyClass[]
  • class MyClass()
  • create class MyClass:
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 len("Hello")?

  • 4
  • 5
  • 6
  • 7
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 output of print(2 ** 3)?

  • 6
  • 8
  • 9
  • 12
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 method is used to combine two strings in Python?

  • append()
  • concat()
  • join()
  • +
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 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

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

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 syntax to output "Hello World" in Python?

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

What is the output of 5 + 3 * 2?

  • 16
  • 11
  • 13
  • 10
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 file extension for Python files?

  • .pt
  • .pyt
  • .pyth
  • .py
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

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

  • 3
  • 3.3
  • 4
  • 3
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

Which of the following is not a keyword in Python?

  • TRUE
  • FALSE
  • None
  • maybe
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 method can be used to return a string in upper case letters?

  • upperCase()
  • upper()
  • uppercase()
  • toUpperCase()
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 operator is used to multiply numbers in Python?

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

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 can you copy a list in Python?

  • list.copy()
  • list[:]
  • Both list.copy() and list[:]
  • copy(list)
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

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