Access your current level in Python

  • The result of the quiz will determine the level to begin.
  • The Quiz contains 12 questions. All questions are mandatory.
  • You will be able to reattempt the quiz after 6 months.

Access your current level in Python

  1. Consider this bit of Python code:
    Code Editor: num_1 = 10 num_2 = 20 num_3 = num_1 num_1 = 100

    What is the final value stored in num_3?

  2. If you want to increment the value stored in the num_1 variable by 10 which of the following Python statements are valid?

  3. Identify the outcome of the following code:
    class Competition:
    __raise_amount = 1.10
    def __init__(self, name, prize):
    self.__name = name
    self.__prize = prize
    def get_name(self):
    return self. name
    def get_prize(self):
    return self.__prize
    def raiseprize(self):
    self.__prize = self.__prize * self__raise_amount
    race = Competition('Race', 100)

  4. What is the result of the following code?
    class Competition:
    def __init__(self, name, prize):
    self.__name = name
    self.__prize = prize
    rowing = Competition('Rowing', 10000)

  5. What is the purpose of the following code?
    class LinkedList:
    def __init__(self):
    self.head = None

  6. Review the following code:
    class MethodSub:
    def __init__(self, number):
    self.number = number
    def __sub__(self, other):
    return self.number + other.number
    num_1 = MethodSub(10)
    num_2 = MethodSub(8)
    print(num_1 - num_2)
    What is the output?

  7. Which statement about threads in Python is true?

  8. Consider the following code:
    import time
    import threading
    from pprint import pprint
    def sleeping_func():
    print(“”nHello from sleeping_fun!“”)
    x = threading.Thread()
    x = threading.Thread(target = sleeping_func)

    When is the sleeping_func() likely to execute?

  9. Review the following Python test script:
    def test_type():
    assert type(1 + 2) is int
    def test_add_int():
    assert 5 + 2 == 7
    def test_string():
    assert 'u' in 'sun'
    def test_add_string():
    assert ('sunny' + 'day') == 'sunnyday'

    You run pytest from the directory that this script is stored. Which test is executed first?

  10. Review the following code statements and identify the correct statement.
    Code Editor(Python):
    from openpyxl.styles import NamedStyle
    custom_style = NamedStyle(name=“header”)
    custom_style.font = Font(bold=True)
    custom_sytle.border = Border(bottom=Side(border_style=“thin”))
    custom_style.alignment = Alignment(horizontal=“center”, vertical=“center”)

  11. What does AF_INET signify in the given code?
    Code Editor:
    import socket

    with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:

  12. What is the result of the following code?

    Code Editor(Python):
    import openpyxl
    work_book = openpyxl.Workbook()

    sheet = work_book['Sheet']
    sheet['A1'] = 'Hello'
    sheet['B1'] = 'Excel'
    sheet['C1'] = 'Users!'