Find The Output of The Following Program in Python
Find The Output of The Following Program in Python
com
Output Questions
Question 1
Find the output of the following program.
def fun(s):
n = len(s)
m=''
for i in range(0, n):
if (s[i] >= 'a' and s[i] <=
'm'):
m = m + s[i].upper()
elif (s[i] >= 'n' and s[i] <=
'z'):
m = m + s[i-1]
elif (s[i].isupper()):
m = m + s[i].lower()
else:
m = m + '#'
print(m)
fun('Gini%Jony')
gIiI#jJon
Question 2.
Find the output of the following program.
def Control(MyNum):
MyNum = MyNum + 10
Withdef(MyNum)
YourNum = 25;
Control(YourNum);
Withdef();
print("Number = " ,YourNum)
Question 3.
Find the output of the following program.
P1 = [20]
P2 = 4
P3 = "school"
Question 4.
Find the output of the following program.
n1 = 150
n2 = 100
n1=Change(n1,n2)
print(n1,"#",n2)
n2=Change(n2)
print(n1,"#",n2)
Question 5.
Find the output of the following program.
def increment(marks):
p=[]
for m in marks:
m = m + 5
if (m>100):
m=100
p.append(m)
return p
def decrement(marks):
for i in range(0,len(marks)):
marks[i] = marks[i] - 5
if (marks[i]<0):
marks[i]=0
a = [45,55,96,85]
a = increment(a)
print(a)
decrement(a)
print(a)
Question 6.
Find the output of the following program.
frequency = { }
list = ['a','b','c','a','c']
for index in list:
if index in frequency:
frequency[index]+=1
else:
frequency[index]=1
print(len(frequency))
print(frequency)
Question 7.
Find the output of the following program.
string = "subordinate"
vowel = "aeiou"
count = 0
print(count)
Question 8.
Observe the following python code carefully
and obtain the output, which will appear on
the screen after execution of it.
Question 9.
Find the output of the following program.
Str1 = "EXAM2020"
Str2 = ""
I=0
while I<len(Str1):
if Str1[I]>="A" and Str1[I]<="M":
Str2=Str2+Str1[I+1]
elif Str1[I]>="0" and Str1[I]<="9":
Str2=Str2+ (Str1[I-1])
else:
Str2=Str2+"*"
I=I+1
print(Str2)
Question 10.
Find the output of the following program.
Str1 = "EXAM2020"
Str2 = ""
I=0
while I<len(Str1):
if Str1[I]>="A" and Str1[I]<="M":
Str2=Str2+Str1[I+1]
elif Str1[I]>="0" and Str1[I]<="9":
Str2=Str2+ (Str1[I-1])
else:
Str2=Str2+"*"
I=I+1
print(Str2)
Question 11.
Find the output of the following program.
def Alter(P=15,Q=10):
P=P*Q
Q=P/Q
print (P,"#",Q)
return Q
A=100
B=200
A=Alter(A,B)
print (A,"$",B)
B=Alter(B)
print (A,"$",B)
A=Alter(A)
print (A,"$",B)
Question 12.
Find the output of the following program.
List = ["P",20,"R",10,"S",30]
Times = 0
Alpha = ""
Sum = 0
for I in range(1,6,2):
Times = Times + I
Alpha = Alpha + List[I-1]+"#"
Sum = Sum + List[I]
print(Times,Sum,Alpha)