Computer Science - Informatics Practices Class XI/XII Python Module Solved Test Part 4
Q1. Write the output of following code.
CODE |
OUTPUT |
a = 10 def
fun(): a=9 a=a+2 print(a) fun() |
|
a = 10 def fun(): a=9 a=a+2 print(a) fun() print(a)
|
|
a = 10 def fun(): global a a=a+2 print(a) fun() print(a)
|
|
a = 10 def fun(): global a a=a+2 print(a) print(a) fun()
|
|
Q2. Write the output of the following:
a = 10
def fun():
global a
a=a+2
print(a)
fun()
print(a)
Q3. Write the output of the following
a = 10
print(a+3)
def fun():
global a
a=a+2
print(a)
fun()
print(a)
Q4. Write the output of the following.
a = 10
print(a*3)
def fun():
print(a)
fun()
print(a)
Q5. Write the output of the following.
a = 10
print(a*3)
def fun(a):
print(a*2)
fun(a)
print(a)
Q6. Write the output of the following:
a = 10
print(a*3)
def fun1(a):
def fun2():
print("hello")
print(a*2)
fun2()
fun1(a)
print(a)
Q7. Write the output of the following.
a = 10
print(a*3)
def fun1(a):
def fun2():
print("hello")
print("hello")
print(a*2)
fun2()
fun1(a)
print(a)
Q8. Write the output of the following.
a = 10
print(a*3)
def fun1(a):
def fun2():
print("hello")
print("hello")
print(a*2)
fun2()
print("hello")
print("hello")
fun1(a)
print(a)
SOLUTION
Q1. Write the output of following code.
CODE | OUTPUT |
a = 10 def fun(): a=9 a=a+2 print(a) fun() | 11 |
a = 10 def fun(): a=9 a=a+2 print(a) fun() print(a)
| 11 10 |
a = 10 def fun(): global a a=a+2 print(a) fun() print(a)
| 12 12 |
a = 10 def fun(): global a a=a+2 print(a) print(a) fun()
| 10 12 |
Q2. Write the output of the following:
a = 10
def fun():
global a
a=a+2
print(a)
fun()
print(a)
Ans
10
12
Q3. Write the output of the following
a = 10
print(a+3)
def fun():
global a
a=a+2
print(a)
fun()
print(a)
Ans.
13
10
12
Q4. Write the output of the following.
a = 10
print(a*3)
def fun():
print(a)
fun()
print(a)
Ans.
30
10
10
Q5. Write the output of the following.
a = 10
print(a*3)
def fun(a):
print(a*2)
fun(a)
print(a)
Ans.
30
20
10
Q6. Write the output of the following:
a = 10
print(a*3)
def fun1(a):
def fun2():
print("hello")
print(a*2)
fun2()
fun1(a)
print(a)
Ans.
30
20
hello
10
Q7. Write the output of the following.
a = 10
print(a*3)
def fun1(a):
def fun2():
print("hello")
print("hello")
print(a*2)
fun2()
fun1(a)
print(a)
Ans.
30
hello
20
hello
10
Q8. Write the output of the following.
a = 10
print(a*3)
def fun1(a):
def fun2():
print("hello")
print("hello")
print(a*2)
fun2()
print("hello")
print("hello")
fun1(a)
print(a)
Ans.
30
hello
hello
20
hello
hello
10
No comments:
Post a Comment