0% found this document useful (0 votes)
10 views4 pages

Python Code Output Predictions

The document contains a series of Python code snippets along with prompts asking for the predicted output of each code. Each code snippet demonstrates various programming concepts such as function definitions, global variables, and string manipulations. The document is aimed at Grade XII Computer Science students at Velammal Vidyalaya in Sholinganallur.

Uploaded by

vishanth P
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)
10 views4 pages

Python Code Output Predictions

The document contains a series of Python code snippets along with prompts asking for the predicted output of each code. Each code snippet demonstrates various programming concepts such as function definitions, global variables, and string manipulations. The document is aimed at Grade XII Computer Science students at Velammal Vidyalaya in Sholinganallur.

Uploaded by

vishanth P
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

Velammal Vidyalaya – Sholinganallur.

Grade XII – Computer Science (083)


Function
1. Predict the output of the following python code:
def runme(x=1, y=2):
x=x+y
y+=1
print(x, ‘$’, y)
return x,y
a, b = runme()
print(a, ‘#’, b)
runme(a,b)
Answer:-
2. Predict the output of the code given below:
def makenew (mystr):
newstr=" "
count=0
for i in mystr:
if count%2!=0:
newstr=newstr+str (count)
else:
if [Link] ():
newstr=newstr+[Link] ()
else:
newstr=newstr+i
count+=1
print (newstr)
makenew("No@1")
Answer:-

1
3. Predict the output of the following python code:
def short_sub (lst,n):
for i in range (0,n):
if len (lst) >4:
lst [i] =lst [i]+lst [i]
else:
lst [i]=lst [i]
subject=['CS', 'HINDI', 'PHYSICS', 'CHEMISTRY', 'MATHS']
short_sub (subject, 5)
print (subject)
Answer:-
4. Predict the output of the following python code:
def Changer(P, Q=10):
P=P/Q
Q=p%Q
return P
A = 200
B = 20
A = Changer(A,B)
print(A, B, sep=’$’)
B = Changer(B)
print(A, B, sep=’$’, end=’###’)
Answer:-
5. Predict the output of the following python code:
a=30
def call (x):
global a
if a%2==0:
x+=a
else:
x-=a
return x
x=20
print (call (35), end="#")
print (call (40), end= "@")
Answer:-
2
6. Predict the output of the following python code:
p=5
def sum(q, r=2):
global p
p=r + q**2
print(p, end= '#')
a=10
b=5
sum(a,b)
sum(r=5,q=1)
Answer:-
7. Predict the output of the following python code:
def change(m, n=10):
global x
x+=m
n+=x
m=n+x
print(m,n,x)
x=20
change(10)
change(20)
Answer:-
8. What will be the output of the following code?
Local=100
def Update(Global=0):
global Local
Local += Global
print(Local, ”#”, Global)
Update(50)
Update()
Answer:-

3
9. What will be the output of the following code?
value = 10
def show(n):
global value
value=25
if value%2==0:
value = value + n
else:
value = value - n
print(value, end='#')
show(20)
print(value, end='%')
Answer:-
10. Find & write the output of the following python code:
def makeNew(mystr):
newstr=’’
count=0
for i in mystr:
if count%2 != 0:
newstr=newstr+str(count)
else:
if [Link]():
newstr=newstr+[Link]()
else:
newstr=newstr+i
count+=1
newstr=newstr+mystr[:1]
print(‘The new string is : ‘, newstr)
makenew(‘sTUdeNT’)

You might also like