Online Exam Quiz

questionQuestion  1 to 30

Which function is used to convert an integer to a string?

  • str()
  • int()
  • toString()
  • convert()
Mark for review

How do you access the first element of a dictionary by its key?

  • dict["key"]
  • dict(0)
  • dict[1]
  • dict.first()
Mark for review

How do you create a class in Python?

  • class MyClass:
  • MyClass class:
  • create MyClass:
  • define MyClass:
Mark for review

How can you add an element to a list?

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

How do you start a comment in Python?

  • //
  • #
  • <!--
  • /*
Mark for review

What is the output of print(type("Hello"))?

  • <type 'string'>
  • <class 'str'>
  • <class 'string'>
  • <type 'str'>
Mark for review

What is the correct file extension for Python files?

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

How do you create a virtual environment in Python?

  • virtualenv venv
  • python -m venv venv
  • create venv
  • mkvirtualenv venv
Mark for review

What is the correct syntax to output the type of a variable or object in Python?

  • print(typeOf(x))
  • print(type(x))
  • print(typeof x)
  • print(typeof(x))
Mark for review

Which keyword is used to check if a value is present in a list, tuple, etc.?

  • exists
  • in
  • on
  • ispresent
Mark for review

How do you create a nested dictionary in Python?

  • dict = {"child1": {"name": "Emil", "year": 2004}, "child2": {"name": "Tobias", "year": 2007}}
  • dict = {"child1" => {"name": "Emil", "year": 2004}, "child2" => {"name": "Tobias", "year": 2007}}
  • dict = {"child1" : ("name": "Emil", "year": 2004), "child2" : ("name": "Tobias", "year": 2007)}
  • dict = {"child1", "name": "Emil", "year": 2004}, {"child2", "name": "Tobias", "year": 2007}
Mark for review

Which keyword is used to define a block of code that will be executed if an exception occurs?

  • else
  • finally
  • except
  • error
Mark for review

How do you start a for loop in Python?

  • for i in range(6)
  • for i to range(6)
  • for i = 1 to 6
  • for (i = 0; i < 6; i++)
Mark for review

Which keyword is used to create a function in Python?

  • func
  • function
  • def
  • define
Mark for review

Which keyword is used to define a lambda function?

  • lambda
  • def
  • func
  • function
Mark for review

Which function is used to get the absolute value of a number?

  • abs()
  • absolute()
  • absv()
  • absvalue()
Mark for review

How do you create a variable with the numeric value 5?

  • x = 5
  • x == 5
  • x := 5
  • x === 5
Mark for review

How do you create a tuple in Python?

  • tuple = ("apple", "banana", "cherry")
  • tuple = ["apple", "banana", "cherry"]
  • tuple = "apple", "banana", "cherry"
  • tuple = {apple, banana, cherry}
Mark for review

What is the correct syntax for defining a class in Python?

  • class ClassName:
  • define ClassName:
  • def ClassName:
  • className Class:
Mark for review

Which method is called when an object is created?

  • start
  • init
  • create
  • new
Mark for review

What is the output of print("Hello"[1])?

  • H
  • e
  • l
  • o
Mark for review

How do you convert a list to a tuple?

  • tuple(list)
  • list(tuple)
  • to_tuple(list)
  • convert(list)
Mark for review

What is the correct way to check if an object is an instance of a class?

  • isinstance(object, class)
  • isobject(class)
  • checkinstance(object, class)
  • isobjectinstance(object, class)
Mark for review

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

  • for
  • foreach
  • while
  • loop
Mark for review

How do you check for equality in Python?

  • a = b
  • a == b
  • a equal b
  • a === b
Mark for review

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

  • 3.33
  • 3
  • 4
  • 2
Mark for review

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

  • list = ["apple", "banana", "cherry"]
  • list = "apple", "banana", "cherry"
  • list = (apple, banana, cherry)
  • list = {apple, banana, cherry}
Mark for review

Which of the following is the correct way to open a file for reading in Python?

  • open("filename", "r")
  • open("filename", "read")
  • openFile("filename", "r")
  • openFile("filename", "read")
Mark for review

How do you write an if statement in Python?

  • if x > y then:
  • if x > y {
  • if x > y:
  • if (x > y)
Mark for review

What is the correct way to get the first element in a list?

  • list[0]
  • list(0)
  • list.first()
  • list[1]
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