If you might have used any python editor, you might have seen some files imported from the library. They help us to avoid writing code from scratch and save some time. Namespace holds all these built-in names and thus is important to keep in mind while any code is being written.
We will test our concepts on namespace and scope in Python in this quiz. Let us start our quiz now.
Time limit: 0
Quiz Summary
0 of 15 Questions completed
Questions:
Information
You have already completed the quiz before. Hence you can not start it again.
What will be the output of the following code snippet?
# Code Snippet Starts
a = 10
def function(a):
a = 20
print(a)
a = 23
function(a)
# Code Snippet Ends
Correct
Incorrect
Question 2 of 15
2. Question
What is the output of the following code snippet? # Code Snippet Starts
num = 10 print(id(num))
# Code Snippet Ends
Correct
Incorrect
Question 3 of 15
3. Question
What is the output of the following code and what is the type of function of print() call? # Code Snippet Starts
value = ‘Apple’ value2 = ‘Pear’ val3 = value+value2 print(val3)
# Code Snippet Ends
Correct
Incorrect
Question 4 of 15
4. Question
What is the output of the following code snippet?
# Code Snippet Starts
s = ‘Quiz-Orbit’
def retriveString(s):
val = (“”).join(s.split(“-“))
return val
print(retriveString(s))
# Code Snippet Ends
Correct
Incorrect
Question 5 of 15
5. Question
What is the output of the following code? # Code Snippet Starts
a = (3,4,5) print(str(id(a))[:4])
# Code Snippet Ends
Correct
Incorrect
Question 6 of 15
6. Question
What is the output of the following code snippet?
# Code Snippet Starts
s = ‘QuizOrbit’
l = len(s)
for i in range(l):
j = i
print(i)
print(“The final value of i is “,j)
# Code Snippet Ends
Correct
Incorrect
Question 7 of 15
7. Question
Find the output of the code given below?
# Code Snippet Starts
s = ‘QuizOrbit is the best to learn Python.’
l = len(s)
for i in range(l):
j = i
i = 0
print(j)
# Code Snippet Ends
Correct
Incorrect
Question 8 of 15
8. Question
What will be the output of the code given below?
# Code Snippet Starts
num = 9
val = 8
def func(a,b):
x = a
y = num+val
print(x+y*b)
print(x,y)
func(5,8)
# Code Snippet Ends
Correct
Incorrect
Question 9 of 15
9. Question
What will be the output of the following code?
# Code Snippet Starts
def function(a):
var = a**2 return var
def callBack(num1,num2):
num1 = function(2)
num2 = function(3)
print(num1*num2)
callBack(3,4)
# Code Snippet Ends
Correct
Incorrect
Question 10 of 15
10. Question
Find the output of the code given below?
# Code Snippet Starts
a = 10
def function(a,b):
print(a+b)
a = 12
b = 38
function(a,b)
# Code Snippet Ends
Correct
Incorrect
Question 11 of 15
11. Question
What is the names of variable in outermost scope?
Correct
Incorrect
Question 12 of 15
12. Question
What do you understand by Global variables in Python?
Correct
Incorrect
Question 13 of 15
13. Question
What is the scope of a variable in Python?
Correct
Incorrect
Question 14 of 15
14. Question
Which of the following is not a type of namespace in Python?
Correct
Incorrect
Question 15 of 15
15. Question
In python how many namespaces can co-exist in a program?
Correct
Incorrect
Summary
Here we come to the end of our Namespace and Scope quiz in Python. This is a very important topic to excel in further learning python. Thus we suggest you first clear any doubts you have in this topic and only then advance further. Don’t forget to drop your feedback. Happy Learning!