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

12 test ch-2

The document contains a series of programming questions focused on Python syntax and output generation. Each question requires the identification and correction of errors in provided code snippets, as well as the prediction of outputs for various Python code segments. The questions cover topics such as loops, string manipulation, and conditional statements.

Uploaded by

risrohit007
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)
15 views

12 test ch-2

The document contains a series of programming questions focused on Python syntax and output generation. Each question requires the identification and correction of errors in provided code snippets, as well as the prediction of outputs for various Python code segments. The questions cover topics such as loops, string manipulation, and conditional statements.

Uploaded by

risrohit007
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
You are on page 1/ 2

Chapter 2.

Python Revision Tour-II(2 Marks Questions)

Q1. Find error in the following code(if any) and correct code by rewriting code
and underline the correction;‐
x= int(“Enter value of x:”)
for in range [0,10]:
if x=y print( x + y)
else: print( x‐y)

Q2. Rewrite the following program after finding and correcting syntactical errors
and underline it.
STRING=""WELCOME NOTE""
for S in range[0,7]:
print (STRING(S))

Q3. FIND OUTPUT OF FOLLOWING


a="WayTOUniversiTY"
z=len(a)
p=0
while p < z:
q=a[p].upper()
if (q=='A' or q=='E' or q=='I' or q=='O' or q=='U'):
print (a[p], end="-")
p=p+1

Q4. Find output generated by the following code:


x="one"
y="two"
c=0
while c<len(x):
print(x[c],y[c])
c=c+1

Q5. Find output generated by the followingcode:


Msg1="WeLcOME"
Msg2="GUeSTs"
Msg3=""
for I in range(0,len(Msg2)+1):
if Msg1[I]>="A" and Msg1[I]<="M":
Msg3=Msg3+Msg1[I]
elif Msg1[I]>="N" and Msg1[I]<="Z":
Msg3=Msg3+Msg2[I]
else:
Msg3=Msg3+"*"
print(Msg3)

Q6. Find and write the output of the following pythoncode:


Text1="AISSCE 2018"
Text2=""
I=0
while I<len(Text1):
if Text1[I]>="0" and Text1[I]<="9":
Val = int(Text1[I])
Val = Val + 1
Text2=Text2 + str(Val)
elif Text1[I]>="A" and Text1[I] <="Z":
Text2=Text2 +(Text1[I+1])
else:
Text2=Text2 + "*"
I=I+1
print(Text2)

Q7. Find output generated by the followingcode:


line = "What will have so will"
L = line.split('a')
for i in L:
print(i, end=' ')

Q.8 Find output


old_msg="PasS@2019"
New_msg=""
for m in old_msg:
if m.isupper():
New_msg+=m.lower()
elif m.islower():
New_msg+=m.upper()
elif m.isdigit():
New_msg+="*"
else:
New_msg+="#"
print("New message is:",New_msg)

Q9. Find output


L =["X",20,"Y",10,"Z",30]
CNT = 0
ST = ""
INC = 0
for C in range(1,6,2):
CNT= CNT + C
ST= ST + L[C-1]+"@"
INC = INC + L[C]
print (CNT,INC,ST)

Q 10. Find output


txt=['20','50','30','40']
cnt=3
total=0
for c in [7,5,4,6]:
t=txt[cnt]
total=float(t)+c
print (total)
cnt-=1

You might also like