Minimum Level Learning
Minimum Level Learning
a=b=10
c=a+b While
c=<20:
print(c,END="*")
c+=10
18
def display(s):
l = len(s)
m=""
for i in range(0,l):
if s[i].isupper():
m=m+s[i].lower()
elif s[i].isalpha():
m=m+s[i].upper()
elif s[i].isdigit():
m=m+"$"
else:
m=m+"*"
print(m)
display("[email protected]")
21 Find and write the output of the following python code:
Msg="CompuTer"
Msg1=''
for i in range(0, len(Msg)):
if Msg[i].isupper():
Msg1=Msg1+Msg[i].lower()
elif i%2==0:
Msg1=Msg1+'*'
else:
Msg1=Msg1+Msg[i].upper()
print(Msg1)
22 Find and write the output of the following python code:
P=6,Q=5
while P<=25:
Q+=10
P+=5
print(P)
print(Q)
23 Find and write the output of the following python code:
for i in range(1,6):
for j in range(1,6):
if i==j:
break
print(j, end='')
print()
24 How many times will the following for loop execute and what‟ s the output?
for i in range(1,3,1):
for j in range(i+1):
print(“*”)
25 What will be the output of the following code:
def JumbleUp(mystr):
L = len(mystr)
str2=''
str3=''
for i in range(0,L,2):
str2=str2 + mystr[i+1]+mystr[i]
for ch in str2:
if ch>='R' and ch<='U':
str3+='$'
else:
str3+=ch.lower()
return str3
mystr="HARMONIOUS"
mystr=JumbleUp(mystr)
print(mystr)
26 Find the write the output of the following code:
def Change(P ,Q=30):
P=P+Q
Q=P-Q
print( P,"#",Q)
return (P)
R=150
S=100
R=Change(R,S)
print(R,"#",S)
S=Change(S)
27 Find and write the output of following python code:
def Alter(M,N=50):
M=M+N
N=M-N
print(M,"@",N)
return M
A=200
B=100
A = Alter(A,B)
print(A,"#",B)
B = Alter(B)
28 Find and write the output of following python code:
def Total(Number=10):
Sum=0
for C in range(1,Number+1):
if C%2==0:
continue
Sum+=C
return Sum
print(Total(4))
print(Total(7))
print(Total())
29 Find and write the output of following python code:
X = 100
def Change(P=10, Q=25):
global X
if P%6==0:
X+=100
else:
X+=50
Sum=P+Q+X
print(P,'#',Q,'$',Sum)
Change()
Change(18,50)
Change(30,100)
30 Find and write the output of following python code:
def Func1(A,B):
if A % B == 0:
return 10
else:
return A + Func1(A,B-1)
val = Func1(20,15)
print(val)
31 What possible outputs(s) are expected to be displayed on screen at the time of execution
of the program from the following code? Also specify the maximum values that can be
assigned to each of the variables FROM and TO.
import random
AR=[20,30,40,50,60,70];
FROM=random.randint(1,3)
TO=random.randint(2,4) for
K in range(FROM,TO+1):
print (AR[K],end=”#“)
32 What possible outputs(s) are expected to be displayed on screen at the time of execution
of the program from the following code? Also specify the maximum values that can be
assigned to each of the variables BEGIN and END.
import random
RUNS = [40,55,60,35,70,50]
BEGIN = random.randint(0,2)
END = random.randint(1,3)
for i in range(BEGIN,END+1):
print(RUNS[i],end='#')
(i) 60#35# (ii) 60#35#70#50#
(iii) 35#70#50# (iv) 40#55#60#
33 What possible outputs(s) are expec ted to be displayed on screen at t he time of
execution of the program from the fo llowing code? Also specify the maxi mum values
that can be assigned to each of the va riables BEGIN and END.
import random
PICKER=random.randint(0,3)
COLORS=["BLUE","PINK","GREEN","R ED"]
for I in COLORS:
for J in range(1,PICKER):
print(I,end="")
print()
(i) (ii)
BLUE BLUE
PINK BLUEPINK
GREEN BLUEPINKGREEN
RED BLUEPINKGREENRED
(iii) (iv)
PINK BLUEBLUE
PINKGREEN PINKPINK
PINKGREENRED GREENGREEN
REDRED
34 Find the output of following Python Code.
35
36 Differentiate between Syntax Error and Run time Error. Also write a suitable example in Python to illustrate
both.
37
Qno. 2
1 What do you understand by the term Iteration?
2 What is the purpose of „break‟ keyword in Loop?
3 What is the difference between List and Tuple?
4 What are the different ways to give comment in Python?
5 What are the correct ways to generate numbers from 0 to 20
(i) range(20) (ii) range(0,21) (iii) range(21) (iv) range(0,20)
6 Name any 2 data types of Python
7 What are the different loops available in Python?
8 What do you understand by the term Recursion?
9 Give any 1 difference between Loop and Recursion
10 What is Mutable data type? Give any example of Mutable data type.
11 Which is the correct form of declaration of dictionary?
(i) Day={1:‟ monday‟ ,2:‟ tuesday‟ ,3:‟ wednesday‟ }
(ii) Day=(1;‟ monday‟ ,2;‟ tuesday‟ ,3;‟ wednesday‟ )
(iii) Day=[1:‟ monday‟ ,2:‟ tuesday‟ ,3:‟ wednesday‟ ]
(iv) Day={1‟ monday‟ ,2‟ tuesday‟ ,3‟ wednesday‟ ]
12 Choose the correct declaration from the following code:
Info = ({„roll‟ :[1,2,3],‟ name‟ :[„amit‟ ,‟ sumit‟ ,‟ rohit‟ ]})
(i) List (ii) Dictionary (iii) String (iv) Tuple
13 Which is the valid dictionary declaration?
i) d1={1:'January',2='February',3:'March'} ii)
d2=(1:'January',2:'February',3:'March'} iii)
d3={1:'January',2:'February',3:'March'}
iv) d4={1:January,2:February,3:March}
14 Given the following dictionary declaration:
Myd={„empno‟ :1,‟ name‟ :‟ Vikrant‟ ,‟ salary‟ :50000}
Raj, Python programmer wants to print all the keys of dictionary and values stored
in dictionary, Help Raj by filling the blanks given in print() statenebt to achieve the
task: print(__________) print(__________)