CARVIEW |
Python Loops , Keywords and Functions
Python Loops , Keywords and Functions Quiz
Question 1
What is the output of the following segment :
print(chr(ord('A')))
A
B
a
Error
Question 2
What is the output of the following program :
y = 8
z = lambda x : x * y
print(z(6))
48
14
64
None of the above
Question 3
What is called when a function is defined inside a class?
Module
Class
Another Function
Method
Question 4
Which of the following is the use of id() function in python?
Id returns the identity of the object
Every object doesn’t have a unique id
All of the mentioned
None of the mentioned
Question 5
What is the output of the following program :
def func(a, b=[]):
b.append(a)
return b
print(func(1))
print(func(2))
[1]
[2][1]
[1, 2][1]
[1]None of the above
Question 6
Suppose li is [3, 4, 5, 20, 5, 25, 1, 3], what is li after li.pop(1)?
[3, 4, 5, 20, 5, 25, 1, 3]
[1, 3, 3, 4, 5, 5, 20, 25]
[3, 5, 20, 5, 25, 1, 3]
[1, 3, 4, 5, 20, 5, 25]
Question 7
To include the use of functions which are present in the random library, we must use the option:import random
import random
random.h
import.random
random.random
Question 8
What will be the output of the following code?
def outer():
x = 10
def inner():
nonlocal x
x += 5
return x
return inner
closure = outer()
print(closure())
print(closure())
15
2015
1510
155
5
Question 9
- To store data
- To repeat actions efficiently
- To create functions
- To handle errors
Question 10
- For loop
- While loop
- Nested loop
- Infinite loop
There are 14 questions to complete.