Computer Science Winter Assignment

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

Computer Science Winter Assignment

Multiple Choice Questions


1. a) Eval
2. a) i,ii,iii,iv,v,vi
3. b) NameError
4. a. indentation Error
5. d) 27.2
6. c. print(‘hello-‘ + ‘how-are-you’)
d. print(‘hello’ + ‘-‘ + ‘how’ + ‘-‘ + ‘are’ + ‘you’)
7. a. total c. Que$tion
8. a) Python only evaluates the second argument if the first one is False
9. d) Explicit type casting
10.b. Mutability
11.c) adds multiple elements at last
12.b) delete 2nd and 3rd element from the list
13.a)4
14.a)del()
15.c. indicates the difference between every two consecutive numbers in the
sequence

Very Short Answer Type Questions

1. 10
2. 30
3. *
**
***

4. * * * * *
****
***
**
*
5. loop will execute infinitely many times
6. 0 ,
1,
2,
3,
4,
5,
6,
7,
8,
9,

7. 0 ,
1,
2,
3,
4,
5,
6,
7,
8,
9,

10

8. 10
9. (5, 5)
10.Type Error
11. [1,2,3,4,5,6,7,8,9]
12. [1, 2, 3, 4, 5, 6, 7, 8]
13. ['b', 'c', 'd']
14. 1
1
15. numbers = [1, 3, 4, 2]
  numbers.sort(reverse = True)
16. (4, 5, 66, 9)
Short Answer Type Questions

1. D = {'A': 20, 'B': 30, 'C':40, 'D': 50}


t=D.items()
for i in t:
print(i)
2. l=[1,2,3,4,5]
n=int(input("enter index of the number to be deleted"))
l.pop(n)
print(l)

3. m=int(input("enter a no."))
n=int(input("enter a no."))
l=[]
l1=[]
for i in range(m,n+1):
print(l.append(i))
for i in l:
if i%2!=0:
print(l1.append(i))

4. d=eval(input("enter items in key-value pair"))


print(dict(d))

5. l=eval(input("enter a list of numbers"))


n=int(input("enter a number to search"))
for i in l:
if n in l:
print(n,"is present")
6. l=[]
for i in range(0,11):
print(l.append(i**2))

You might also like