0% found this document useful (0 votes)
23 views18 pages

Class Computer CSR Type Question

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views18 pages

Class Computer CSR Type Question

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 18

num = 1

def myfunc():
num = 10
return num
print(num)
print(myfunc())
print(num)
my_dict={}
my_dict[(1,2,4)]= 8
my_dict[(4,2,1)]=10
my_dict[(1,2)]=12
sum = 0
for k in my_dict:
sum += my_dict[k]
print (sum)
print(my_dict)
my_dict={}
my_dict[(1,2,4)]= 8
my_dict[(4,2,1)]=10
my_dict[(1,2)]=12
sum = 0
for k in my_dict:
sum += my_dict[k]
print (sum)
print(my_dict)
import random
S=["Pen","Pencil","Eraser","Bag","Book"]
for i in range (1,2):
f=random.randint(i,3)
s=random.randint(i+1,4)
print(S[f],S[s],sep=":")

I. Pencil:Book
II. Pencil:Book Eraser:Bag
III. Pen:Book Bag:Book
IV. Bag:Eraser
dict = {}
a, b, c = 15, 25, 35
dict[a, b, c] = a + b - c
a, b, c = 25, 20, 40
dict[a, b, c] = a + b - c
print(dict)
dc1 = { }
dc1[1] = 1
dc1['1'] = 2
dc1[1.0] = 4
sum = 0
for k in dc1:
sum += dc1[k]
print (sum)
dc1 = { }
dc1[1] = 1
dc1['1'] = 2
dc1[1.0] = 4
sum = 0
for k in dc1:
sum += dc1[k]
print (sum)
print(dc1)
import random
n1= random.randrange(1, 10, 2)
n2= random.randrange(1, 10, 3)
print (n1,"and",n2)

(a) 2 and 7
(b) 3 and 4
(c) 8 and 10
(d) 8 and 9
l=[]
for i in range(4):
l.append(2*i+1)
print(l[ : :-1])
l=[]
for i in range(4):
l.append(2*i+1)
print(l[ : :-1])
a = [1, 2, 3, 4]
b = [3, 4, 5, 6]
c = []
for val in a:
if val not in b:
c.append(val)
print(c)
Consider the following operation performed on a stack of size 5.
Push(1)
Pop()
Push(2)
Push(3)
Pop()
Push(4)
Pop()
Pop()
Push(5)
Write the output of the code given below:
dict1 = {"name": "Suman", "age": 36}
dict1['age'] = 27
dict1['address'] = "Chennai"
print(dict1.keys())
Predict the output of the following Python code:
tup1 = ("George", "Anderson", "Mike", "Luke", "Amanda")
list1 =list(tup1)
list2 = []
for i in list1:
if i[-1]=="e":
list2.append(i)
tup2 = tuple(list2)
print(tup2)
tup1 = ("Manish", "Ande", "Mike", "Luke", "Ananda")
list1 =list(tup1)
list2 = []
for i in list1:
if i[-1]=="e":
list2.append(i)
tup2 = tuple(list2)
print(tup2)
def fun(s):
k=len(s)
m=" "
for i in range(0,k):
if(s[i].isupper()):
m=m+s[i].lower()
elif s[i].isalpha():
m=m+s[i].upper()
else:
m=m*'bb'
print(m)
fun('school2@com')
def fun(s):
k=len(s)
m=" "
for i in range(0,k):
if(s[i].isupper()):
m=m+s[i].lower()
elif s[i].isalpha():
m=m+s[i].upper()
else:
m=m+'bb'
print(m)
fun('school2@com')

You might also like