XII Assignment
Computer Science
Question1) Differentiate between while loop and for loop.
Question 2) Convert the following while loop into for loop.
y,z=100,10
while y<=200:
print(z,end='^')
y=y+50
z+=y
Question 3)Find the output of the following code :
t=10
for x in range(50,0,-10):
print(x*t)
t+=10
else:
print("x=",x*t)
Question 4)Find the output of the following code:
s=5
for i in range(13,30,7):
print(str((i-1)%10)+'$',str(s*s)[-1],end='@')
s+=1
Question 5)Find the output of the following code:
for j in range(2,11,2):
y=j*2.0-1
if y%3==0:
print(j+y,end='&')
else:
print(str(int(y%3))*2+'#')
Question 6)Rewrite the following code after correcting the errors:
z,y=20
for x in "qqqq":
if y=<20:
if x in "qwerty":
Pass
else:
print "Done"
Question 7)Rewrite code after making necessary corrections to execute this code
successfully:
a=5
print("my first program","Display on screen",sep='\T')
for g in range(10,1:-1):
a,b=15%%5,15//5
print(a=b)
else:print("program finished")
Question 8)How many times 'X' will appear on screen?
c=0
for i in range(1,11):
for j in range(1,6):
print('X')
Question 9)Find the output of the following code:
for x in range(1,3):
for y in range(3,1,-1):
if y%2==0:
print(str(x)+str(y),float(x*y*2),sep='@@ ',end='& ')
else:
print(x+y,float(x*y),sep='##')
Question 10)Find the output of the following code:
for x in range(1,3):
for y in range(1,3):
if y%2!=0:
print(y)
continue
else:
break
else:
print("end1")
else:
print ("end 2")