Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

Grade 12 Computer Science 01-03-24

I. Answer the following questions:


What will be the output of the following code:
1. EXAM="COMPUTER SCIENCE"
print(EXAM[:12:-2])
2. Tuple1=(10,)
Tuple2=Tuple1*2
print(Tuple2)
3. a=tuple()
a=a + tuple('Python')
print(a)
print(len(a))
b=(10,20,30)
print(len(b))
4. tuple1 = (33, 24, 44, 42, 54 ,65)
list1 =list(tuple1)
new_list = []
for i in list1:
if i>40:
new_list.append(i)
new_tuple = tuple(new_list)
print(new_tuple)
5. dictcount={"age1":26,"age2":32,"age3":40}
sum=0
for key in dictcount:
sum=sum+dictcount[key]
print(sum)
6. Sum = 0
for k in range(10 , 1, -2):
Sum = Sum+k
print(Sum)
7. l1 = [10,15,16,18,20]
l1.remove(15)
l1.insert(1,30)
print (l1[::-2])
8. str = "Cricket World Cup in Australia"
str2 = str[:7] + " " + str[18:] + "."
print(str2)
9. sub = "083 Comp. Sc. & 065 Info. Prac."
n = len(sub)
s=''
for i in range(n):
if sub[i].isupper():
s = s + sub[i].lower()
elif sub[i].islower():
s = s + sub[i]
elif sub[i].isdigit():
s = s + 'x'
elif sub[i].isspace():
pass
else:
s = s + '!'
print(s)
10. colors=["violet", "indigo", "blue", "green", "yellow", "orange", "red"]
del colors[4]
colors.remove("blue")
colors.pop(3)
print(colors)
11. rec={"Name":"Python","Age":"20","Addr":"NJ","Country":"USA"}
id1=id(rec)
del rec
rec={"Name":"Python","Age":"20","Addr":"NJ","Country":"USA"}
id2=id(rec)
print(id1==id2)
12. dc1={ }
dc1[1]=1
dc1['1']=2
dc1[1.0]=4
sum=0
for k in dc1:
sum+=dc1[k]
print(sum)
13. tuple1=('Jayesh','Ramya','Taruna','Suraj')
list1=list(tuple1)
for Name in list1:
if Name[0]=='T':
break
else:
print("Finished")
print("Got it!")
14. S= "python is very funny language"
print(S.split("n"))
15. Color = 'Color helps to give shadow to the picture'
newcolor = Color.replace('o','#')
print(newcolor)
16. T=25,26,27,28,29
L=list(T)
NL=[]
for I in L:
if(i%2==0):
NL.append(i)
else:
NL.append(i-1)
NP=tuple(NL)
print(NP)

You might also like