Python is an interpreted language. Which of the following statements correctly describes an interpreted language?
Python will save all code first prior to running.
The source code is converted into bytecode that is then executed by the Python virtual machine.
Python needs to be built prior to it being run.
The source code is pre-built and compiled before running.
Why is indentation important in Python?
The code will compile faster with indentation.
Python used indentation to determine which code block starts and ends.
It makes the code more readable.
The code will be read in a sequential manner
What will be the output of the following code?
names = ["Anna", "Natasha", "Mike"] names.insert(2, "Xi") print(names)
[“Anna”, “Natasha”, Xi]
[“Anna”, “Xi”, ”Mike” ]
[“Anna”, “Natasha”, 2, “Xi”, “Mike”]
[“Anna”, “Natasha”, “Xi”, “Mike”]
What will be the output of the code below?
print(int((str((float(x))))))
Will give an error
1.0, 2.0
“one”, “two”
1 , 2
What will be the output of the following code:
sample_dict = {1: 'Coffee', 2: 'Tea', 3: 'Juice'} for x in sample_dict: print(x)
1 2 3
{1 2 3}
‘Coffee’, ‘Tea’, ‘Juice’
(1, 'Coffee')
(2, 'Tea')
(3, 'Juice')
What will be the output of the recursive code below?
def recursion(num): print(num) next = num - 3 if next > 1: recursion(next) recursion(11)
2 5 8 11
11 8 5 2
8 5 2
2 5 8
What will be the type of time complexity for the following piece of code:
def bigo(numbers): for i in numbers: print(numbers) bigo([1, 7, 13, 19])
Quadratic Time
Logarithmic Time
Linear Time
Constant Time
What will be the output of the code below:
str = 'Pomodoro' for l in str: if l == 'o': str = str.split() print(str, end=", ")
[‘Pomodoro’, ‘modoro’, ‘doro‘, ‘ro’]
Will throw an error
['Pomodoro']
[‘P’, ‘m’, ‘d’, ‘o’]
Find the output of the code below:
def d(): color = "green" def e(): nonlocal color color = "yellow" e() print("Color: " + color) color = "red" color = "blue" d()
red
yellow
green
blue
Find the output of the code below:
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
9
2
5
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))
print(issubclass(C,P))
Django is a type of:
Asynchronous framework
Micro-framework
Full-stack framework
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.
It is where the application is tested as a whole.
It combines unit tests.
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
False
What will be the output of the code below:
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())
Function inside B
None of the above
No output
Function inside A