# End-of-Course Graded Assessment: Using Python

1. **Python is an interpreted language. Which of the following statements correctly describes an interpreted language?**
    
    * Python will save all code first prior to running.
        
    * <mark>The source code is converted into bytecode that is then executed by the Python virtual machine.</mark>
        
    * Python needs to be built prior to it being run.
        
    * The source code is pre-built and compiled before running.
        
2. **Why is indentation important in Python?**
    
    * The code will compile faster with indentation.
        
    * <mark>Python used indentation to determine which code block starts and ends.</mark>
        
    * It makes the code more readable.
        
    * The code will be read in a sequential manner
        
3. **What will be the output of the following code?**
    
    ```python
    names = ["Anna", "Natasha", "Mike"]
    names.insert(2, "Xi")
    print(names)
    ```
    
    * \[“Anna”, “Natasha”, Xi\]
        
    * \[“Anna”, “Xi”, ”Mike” \]
        
    * \[“Anna”, “Natasha”, 2, “Xi”, “Mike”\]
        
    * <mark>[“Anna”, “Natasha”, “Xi”, “Mike”]</mark>
        
4. **What will be the output of the code below?**
    
    ```python
    print(int((str((float(x))))))
    ```
    
    * <mark>Will give an error</mark>
        
    * 1.0, 2.0
        
    * “one”, “two”
        
    * 1 , 2
        
5. **What will be the output of the following code:**
    
    ```python
    sample_dict = {1: 'Coffee', 2: 'Tea', 3: 'Juice'}
    for x in sample_dict:
        print(x)
    ```
    
    * <mark>1 2 3</mark>
        
    * {1 2 3}
        
    * ‘Coffee’, ‘Tea’, ‘Juice’
        
    * (1, 'Coffee')
        
        (2, 'Tea')
        
        (3, 'Juice')
        
6. **What will be the output of the recursive code below?**
    
    ```python
    def recursion(num):
        print(num)
        next = num - 3
        if next > 1:
            recursion(next)
    recursion(11)
    ```
    
    * 2 5 8 11
        
    * <mark>11 8 5 2</mark>
        
    * 8 5 2
        
    * 2 5 8
        
7. **What will be the type of time complexity for the following piece of code:**
    
    ```python
    def bigo(numbers):
        for i in numbers:
            print(numbers)
    
    bigo([1, 7, 13, 19])
    ```
    
    * Quadratic Time
        
    * Logarithmic Time
        
    * <mark>Linear Time</mark>
        
    * Constant Time
        
8. **What will be the output of the code below:**
    
    ```python
    str = 'Pomodoro'
    for l in str:
    if l == 'o':
        str = str.split()
        print(str, end=", ")
    ```
    
    * \[‘Pomodoro’, ‘modoro’, ‘doro‘, ‘ro’\]
        
    * <mark>Will throw an error</mark>
        
    * \['Pomodoro'\]
        
    * \[‘P’, ‘m’, ‘d’, ‘o’\]
        
9. **Find the output of the code below:**
    
    ```python
    def d():
        color = "green"
        def e():
            nonlocal color
            color = "yellow"
        e()
        print("Color: " + color)
        color = "red"
    color = "blue"
    d()
    ```
    
    * <mark>red</mark>
        
    * yellow
        
    * green
        
    * blue
        
10. **Find the output of the code below:**
    
    ```python
    num = 9
    class Car:
        num = 5
        bathrooms = 2
    
    def cost_evaluation(num):
        num = 10
        return num
    
    class Bike():
        num = 11
    
    cost_evaluation(num)
    car = Car()
    bike = Bike()
    car.num = 7
    Car.num = 2
    print(num)
    ```
    
    * 10
        
    * <mark>9</mark>
        
    * 2
        
    * 5
        
11. **Which of the following is the correct implementation that will return True if there is a parent class P, with an object p and a sub-class called C, with an object c?**
    
    * print(issubclass(P,C))
        
    * print(issubclass(C,c))
        
    * print(issubclass(p,C))
        
    * <mark>print(issubclass(C,P))</mark>
        
12. **Django is a type of:**
    
    * Asynchronous framework
        
    * Micro-framework
        
    * <mark>Full-stack framework</mark>
        
13. **Which of the following is not true about Integration testing:**
    
    * Primarily dealt by the tester.
        
    * Tests the flow of data from one component to another.
        
    * <mark>It is where the application is tested as a whole.</mark>
        
    * It combines unit tests.
        
14. **While using pytest for testing, it is necessary to run the file containing the main code before we can run the testing file containing our unit tests.**
    
    * True
        
    * <mark>False</mark>
        
15. **What will be the output of the code below:**
    
    ```python
    class A:
       def a(self):
           return "Function inside A"
    
    class B:
       def a(self):
           return "Function inside B"
    
    class C:
       pass
    
    class D(C, A, B):
       pass
    
    d = D()
    print(d.a())
    ```
    
    * <mark>Function inside B</mark>
        
    * None of the above
        
    * No output
        
    * Function inside A
        

---

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1731057397265/b7023ebc-26dd-4221-b971-da1795c40b3d.png align="center")
