0% found this document useful (0 votes)
24 views3 pages

Python Code Output Predictions

The document contains multiple Python code snippets that demonstrate string manipulation and list processing. It includes functions to change case based on character type, replace list elements based on odd/even values, filter numbers ending with 5, and store student names and percentages in a dictionary. Additionally, it shows how to create a tuple of powers of a user-defined number.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views3 pages

Python Code Output Predictions

The document contains multiple Python code snippets that demonstrate string manipulation and list processing. It includes functions to change case based on character type, replace list elements based on odd/even values, filter numbers ending with 5, and store student names and percentages in a dictionary. Additionally, it shows how to create a tuple of powers of a user-defined number.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

26 Predict the output for the following code:

def string_change():
str1=’Annual Exam 23'
str2=''
for i in str1:
if [Link]():aNNUAL$eXAM$46
str2+=[Link]()
elif [Link]():
str2+=[Link]()
elif [Link]():
str2+=i*2
else:
str2+='$'
print(str2)
string_change()

Output: aNNUAL$eXAM$46
OR

What will be the output of the following program:


def change():
s="Annual Exam"
m=""
for i in range(0, len(s)):
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)
change()

OUTPUT: aAnnAL#eEAM
27 Write a Python program to input a list and replace the odd elements of the list with
three times the value and even elements with two times the value.
Eg)If L=[3,6,8,5,1],output should be [9,12,16,15,3]
OR
Write a Python program to input a list and store the numbers ending with 5 in
another list and display it.
Eg)If L=[34,26,35,985,44] output should be [35,985]
28 Write a Python program to input name and percentage of n number of students, as
per the user’s [Link] the name as the key and percentage as [Link]
display the name of the student who has secured more than 75 percentage.
OR
Write a Python program to input x from the user,n times as per the user’s choice and
store x**i in a [Link] should have (x**1,x**2,x**3……..x**n) after the execution

27)i
n=int(input("enter n"))
l1=[]
for i in range(n):
x=int(input("enter number"))
[Link](x)
for i in range(len(l1)):
if l1[i]%2==0:
l1[i]=l1[i]*2
else:
l1[i]=l1[i]*3
print(l1)

ii) n=int(input("enter n"))


l1=[]
for i in range(n):
x=int(input("enter number"))
[Link](x)
l2=[]
for i in l1:
if i%10==5:
[Link](i)
print(l2)

28)i)
d1={}
n=int(input("enter n"))
for i in range(n):
a=input("enter name")
b=int(input("enter percent"))
d1[a]=b
l1=[]
for i in [Link]():
if d1[i]>=75:
[Link](i)
print(l1)

ii)
x=int(input("enter number"))
n=int(input("enter num2"))
t1=()
for i in range(n):
t1+=(x**i,)
print(t1)

You might also like