Quiz on Python Variable Scope
FREE Online Courses: Dive into Knowledge for Free. Learn More!
Quiz Summary
0 of 15 Questions completed
Questions:
Information
You have already completed the quiz before. Hence you can not start it again.
Quiz is loading…
You must sign in or sign up to start the quiz.
You must first complete the following:
Results
Results
0 of 15 Questions answered correctly
Your time:
Time has elapsed
You have reached 0 of 0 point(s), (0)
Earned Point(s): 0 of 0, (0)
0 Essay(s) Pending (Possible Point(s): 0)
Categories
- Not categorized 0%
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- Current
- Review / Skip
- Answered
- Correct
- Incorrect
-
Question 1 of 15
1. Question
Which of the following is true about local variables?
CorrectIncorrect -
Question 2 of 15
2. Question
Which of the following is not the scope of a variable?
CorrectIncorrect -
Question 3 of 15
3. Question
name=”Python”
def func():
name=”PythonGeeks”
print(name)
CorrectIncorrect -
Question 4 of 15
4. Question
- Which of the following is a built-in variable?
CorrectIncorrect -
Question 5 of 15
5. Question
n=4
def f1():
n=n**4
print(n)
f1()
CorrectIncorrect -
Question 6 of 15
6. Question
- Which keyword is used to reflect the changes done in the nested function at the outer function?
CorrectIncorrect -
Question 7 of 15
7. Question
n=6
def fun1():
n=4.5
def fun2():
global n
n=3.2
fun2()
fun1()
print(n)
CorrectIncorrect -
Question 8 of 15
8. Question
Which of the following coding blocks does not give an error?
a.
def f1():
def f2():
global m
m=3
f2()
print(m)
f1()
b.
def f1():
def f2():
global m
m=3
print(m)
f1()
c.
def f1():
def f2():
m=3
f2()
print(m)
f1()
d.
def f1():
def f2():
global m
m=3
f2()
Print(m)
f1()
CorrectIncorrect -
Question 9 of 15
9. Question
Which of the following is the output of the following code?
def func1():
num=12
def func2():
nonlocal num
num=7
func2()
func1()
print(num)CorrectIncorrect -
Question 10 of 15
10. Question
x=4
def fun():
a=4
global x
x=4
print(a)
fun()
CorrectIncorrect -
Question 11 of 15
11. Question
n=3
def fun1():
global n=1
fun1()
print(n)
CorrectIncorrect -
Question 12 of 15
12. Question
What is the scope of the nested functions?
CorrectIncorrect -
Question 13 of 15
13. Question
def fun():
x=x+1
print(x)
x=12
print(x)
CorrectIncorrect -
Question 14 of 15
14. Question
Which of the following coding blocks gives the output as “Python”?
a.
def fun1():
name=”a”
def fun2():
nonlocal name
name=”PythonGeeks”
fun2()
print(name)
fun1()
b.
def fun1():
name=”a”
def fun2():
nonlocal name
name=”PythonGeeks”
print(name)
fun1()
c.
def fun1():
name=”a”
def fun2():
name=”PythonGeeks”
fun2()
print(name)
fun1()
d.
def fun1():
name=”a”
def fun2():
nonlocal name=”PythonGeeks”
fun2()
print(name)
fun1()
CorrectIncorrect -
Question 15 of 15
15. Question
What is the output of the following code?
def fun1():
name=”a”print(fun1())
print(name)CorrectIncorrect