You are on page 1of 6

WORKSHEET – 2

Class – XII (CS / IP) Name of chapters: String, Dictionary


1. Write output of given python program after removing errors: (3)

2. Complete python program by writing missing statements as per instructions given (6)
below and find output of completed program.

3. Complete python program by writing missing statements as per instructions given (6)
below and find output of completed program.

4. Write output of given python program after removing errors: (3)

5. Write output of given python program after removing errors: (3)


6. Write output of given python program after removing errors: (3)

7. Write output of given python program after removing errors: (2)

8. Write a statement in python to remove all the values from dictionary D. (2)
Write a statement in python to remove entire dictionary D.
9. Write missing statements 1 - 4 as per instructions given below and find output of (10)
completed code.
10. Rewrite below code after removing all the possible errors by underlining each (5)
correction and write output of corrected code:

11. Rewrite the following code in python after removing all syntax error(s). Underline (5)
each correction done in the code. Also find output.

12. Find and write the output of the following python code : (2)

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)

13. Observe given program carefully and rewrite program after correcting syntax errors. (4)
Underline each correction. Also find output of corrected program:

s= SiliCOn ValleY"

print(s[2::2]

print(s[4].isupper())

print(s(-3::-2))

print(s[-5::]

print(s[9]);

print(s.lower())

14. Find output of given python code after removing syntax errors. Underline each correction. (6)

s="HelloIndia2021"

s1=s[::-3]

s=s+s1

print(s[::-1])

for i in s[::2]

if i.isupper():

print(" * ’,end='')

elif i.islower():

print("$",end='')

Else:

print(i,end='')

print()

print(s.isalpha()

print(s.isalnum())

print(s*(len(s1)//2))

15. Rewrite the following code in Python after removing all syntax error(s). Underline each (3)
correction done in the code.
STRING=""HAPPY NEW YEAR"
for S in range[0,8]:
print STRING(S)
print S,STRING
16. Write the output of the following code: (2)
Text="@Shop2HomeDelivery"
L=len(Text)
n=""
for i in range(0,L):
if Text[i].isupper():
n=n+Text[i].lower()
elif Text[i].isalpha():
n=n+Text[i].upper()
else:
n=n+'##'
print(n)

You might also like