Q1. What will be the output of the following code:
1 |
len("AILearner") |
- 8
- 9
- 10
- Error!
Q2. What will be the output of following code:
1 2 3 4 5 6 7 8 9 10 11 12 |
import math def func1(a): return a*a def func2(a): return math.sqrt(a) def func3(a): return math.ceil(func1(a)+func2(a)) print(func3(2)) |
- 5
- 6
- 5.14
- 7
Q3. What will be the output of following code:
1 2 3 4 5 6 7 |
x = { "a": 1, "b": 2, "c": 3 } x.popitem("a") print(x) |
- {‘a’: 1, ‘b’: 2, ‘c’: 3}
- {‘c’: 3}
- {‘a’: 1, ‘b’: 2}
- TypeError
Q4. Which of the following statements is not true?
- We can change the value of a private variable of superclass in the subclass
- Superclass non-private method can be overridden.
- The constructor of a class in invoked automatically.
- A derived class is a subclass of superclass
Q5. What type of error will be raised when the imported module is not found?
- ImportError
- NullPointerError
- NameError
- IndexNotFoundError
Q6. How does Python treat a string literal when it is not assigned to any variable?
- It will ignore the string literal.
- It will automatically assings a variable to it.
- It will through an error.
- None of the above.
Q7. In Python, which of the following variable is not of a integer data type?
- x = 435757438
- x = 5
- x = 23.45
- x = -5
Q8. Which of the following statement will extract the percentage of the mentioned student?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
import json j1 = """{ "School":{ "student":{ "name":"Harry", "result":{ "marks":"70", "percentage":"70%" } } } }""" data = json.loads(j1) |
- print(data[‘school’][‘student’][‘result’][‘percentage’])
- print(data[‘School’][‘student’][‘result’][‘percentage’])
- print(data[‘School’][‘student’][‘result’][0])
- print(data[‘Sschool’][‘student’][0][‘percentage’])