CS Worksheet
CS Worksheet
Page :1
Output of
(i) 2 * 7 =
(ii) 2 ** 7 =
17 (iii) 2**2**3 =
(iv) 17 % 20 =
(v) not(20>6) or (19>7) and (20==20) =
Output of :
a,b,c = 20,40,60
18 b+=10
c+=b
print(a,b,c)
19 Write a program to enter 2 number and find sum and product
Write a program to enter temperature in Fahrenheit and convert it
20
in Celsius
Write a program to enter any money and find out number of
denominations can be used to make that money. For e.g. if the money
entered is 2560
Then output should be
2000 = 1
500 = 1
200 = 0
21 100 =0
50 =1
20 = 0
10 = 1
5 = 0
2 = 0
1 = 0
Hint : use % and // operator (Without Loop / Recursion)
Consider a list:
MyFamily = [“Father”,”Mother”,”Brother”,”Sister”,”Jacky”]
Page :2
Write statements:
(i) to print employee name
(ii) to update the salary from 80000 to 90000
(iii) to get all the values only from the dictionary
Num = 100
Isok = False
28 print(type(Num)) =
print(type(Isok)) =
Page :3
What is type conversion in Python? What are different types of
35
conversion? Illustrate with example.
Fill in the blanks to execute infinite loop:
36 while :
print(“spinning”)
Write a program to enter any number and check it is divisible by 7
37
or not
Fill in the blanks to execute loop from 10 to 100 and 10 to 1
(i)
for i in range( ):
print(i)
38
(ii)
for i in range( ):
print(i)
What will be the output if entered number (n) is 10 and 11
i=2
while i<n:
if num % i==0:
break
39
print(i)
i=i+1
else:
print("done")
Write a program that prompt for a phone number of 10digits and two
40 dashes , with dashes after the area code next three numbers For
Example 017-555-1212 is a legal output
import random
AR=[20,30,40,50,60,70];
41 FROM=random.randint(1,3)
TO=random.randint(2,4)
for K in range(FROM,TO+1):
print (AR[K],end=”#“)
(i) 10#40#70#
(ii) 30#40#50#
(ii) 50#60#70#
(iv) 40#50#70#
Page :4
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 minimum and maximum value that can be assigned to the
variable PICKER.
import random
PICKER=random.randint(0,3)
COLORS=["BLUE","PINK","GREEN","RED"]
for I in COLORS:
for J in range(1,PICKER):
42 print(I,end="")
print()
(i) (ii)
BLUE BLUE
PINK BLUEPINK
GREEN BLUEPINKGREEN
RED BLUEPINKGREENRED
(iii) (iv)
PINK BLUEBLUE
PINKGREEN PINKPINK
PINKGREENRED GREENGREEN
REDRED
Page :5
colors.remove("blue")
p=colors.pop(3)
print(p, colors)
Output of following code:
A=10
B=15
S=0
while A<=B:
51 S = A + B
A = A + 10
B = B + 10
if A>=40:
A = A + 100
print(S)
Output of the following code:
X = 17
if X>=17:
52 X+=10
else:
X-=10
print(X)
How many times loop will execute:
P=5
53 Q=35
while P<=Q:
P+=6
Find and write the output of the following python code:
Msg="CompuTer"
Msg1=''
for i in range(0, len(Msg)):
if Msg[i].isupper():
54 Msg1=Msg1+Msg[i].lower()
elif i%2==0:
Msg1=Msg1+'*'
else:
Msg1=Msg1+Msg[i].upper()
print(Msg1)
A=10
B=10
55 print( A == B) = ?
print(id(A) == id(B) = ?
print(A is B) = ?
Page :6