Q1. What will be the output of following code:
1 2 3 4 5 6 |
def fun(a, b): def in_fun(c, d): return c*d return in_fun(a, b) print(fun(5, 10)) |
- 15
- 5
- 50
- Error
Q2. Which of the following function is used inside a for loop in Python?
- count()
- iterate()
- next()
- new()
Q3. What will be the output of following code:
1 2 3 4 5 6 7 8 9 10 11 |
if 2 in {'x': 1, 'y': 2, 'z': 3}: print(1) print(2) if 'e' in 'TheAILearner': print(3) elif 'y' in {'x': 1, 'y': 2, 'z': 3}: print('x') print('y') if 't'in 'TheAILearner': print('z') print("Great!") |
- 1
2
Great! - x
y
Great! - 1
2
3
Great! - x
y
z
Great!
Q4. What will be the output of following code:
1 2 |
x = ("a", 2, 3, 2, 2.3, [1, 2,3]) print(len(x)) |
- 5
- 8
- 6
- TypeError!
Q5. Which of the following statement will return False?
- bool(-1)
- bool(1)
- bool(0)
- bool(12E5)
Q6. Which of the following brackets can be used to create lists in Python?
- []
- {}
- ()
- <>
Q7. In Python, what is the correct way of casting an integer value to a string?
- x = str(6)
- x = Integer.toString(6);
- Both of the above.
- None of the above.
Q8. What will be the output of following code:
1 |
"TheAILearner".count("a", 0, 5) |
- 0
- 1
- 2
- Throws an error!