0% found this document useful (0 votes)
42 views

Python Output Questions (Functions) : Muhammed Ramsan K: 9961649395

The document contains 10 questions related to Python functions. Each question defines one or more functions and calls them to demonstrate their behavior. The questions cover if/else conditional logic, returning values from functions, passing arguments, modifying global variables, and order of operations. An answer key is provided at the end to show the expected output for each question.

Uploaded by

Aditya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
42 views

Python Output Questions (Functions) : Muhammed Ramsan K: 9961649395

The document contains 10 questions related to Python functions. Each question defines one or more functions and calls them to demonstrate their behavior. The questions cover if/else conditional logic, returning values from functions, passing arguments, modifying global variables, and order of operations. An answer key is provided at the end to show the expected output for each question.

Uploaded by

Aditya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

PYTHON OUTPUT QUESTIONS ( FUNCTIONS)

Q1.
def d(a,b): r=150
if(a>b):print(a) s=100
elif(a==b):print('equal') r=chan(r,s)
else:print(b) print(r,"#",s)
print(d(10,20)) s=chan(s)
Q2. print(r,"#",s)
def d(a,b):
if(a>b):print(a) Q5.
elif(a==b):print('equal') a=10
else:print(b) def add(x):
print(d(10,20)) print(x)
d(10,20) def sub(y):
print() print(y)
print(a)
Q3. a=20
def d(a,b): print(a)
if(a>b):return(a) add(100)
elif(a==b):return('equal') sub(200)
else:return(b) Q6.
print(d(10,20)) a=10
c=d(100,20) def add(x):
print(c) print(x)
def sub(y):
Q4. print(y)
def chan(p,q=30): print(a)
p=p+q a=20
q=p-q print(a)
print(p,"#",q) add(100)
return p sub(200)

Muhammed Ramsan K : 9961649395


Q7. Q9.
def add(x): a=10
print(x) def disp():
x=x+2 global a
print(x+a) print(a)
def sub(y): a=a+5
print(y+a) def show(x):
y=y*2 global a
print(y) print(a)
#main a=a*2
a=10
add(a);print(a); a=20 ; sub(a) ; #main
print(a);
disp()
x=4 ; y=5
show(a)
add(x); print(x)
a=25
sub(y); print(y)
disp()
show(a)
Q8.
a=10
def disp():
a=20
print(a)
def show(a):
print(a)
a=60
print(a)
#main
disp()
show(a)
a=25
disp()
show(a)
Muhammed Ramsan K : 9961649395
Answers Q7.
Q1. 10
20 22
None 10
Q2. 40
20 40
None 20
20 4
Q3. 26
20 4
100 25
Q4. 10
250 # 150 5
250 # 100 Q8.
130 # 100 20
250 # 130 10
Q5. 60
10 20
20 25
100 60
200 Q9.
Q6. 10
10 15
12 25
20 30
40 Q10.
4
6
5
10

Muhammed Ramsan K : 9961649395

You might also like