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

Class XI Second Term Computer Science Weekly Test 2022-23 Marking Scheme

1. Identify the correct statement: [1]


a) List is an immutable data type
b) Tuple is a mutable data type
c) List is a mutable data type
d) Tuple elements can be updated

2. Identify the correct statement: [1]


a) Mutable can be updated
b) Immutable can be updated
c) Data types int, float and str are mutable type
d) Dictionary is an immutable data type

3. Identify the correct statement: [1]


xyz=(100+"200")
a) Variable xyz is a tuple
b) Statement triggers an error
c) Variable xyz is an int
d) Variable xyz is a string

4. Identify the correct statement: [1]


a) sorted() is list method
b) sort() is built-in function
c) sorted() returns a sorted list
d) sort() returns a sorted list

5. Identify the statement that will trigger an error: [1]


a) astr='''Soccer World Cup 2022'''
b) astr="Football"+astr[6:]
c) astr[12]='-'
d) print(max(astr))

6. Identify the Python statements, that will produce identical output: [1]
a) print('faips'.swapcase()); print('faips'.upper())
b) print('FaIpS'.swapcase()); print('fAiPs'.lower())
c) print('FaIpS'.swapcase()); print('fAiPs'.upper())
d) print('FaIpS'.upper()); print('fAiPs'.lower())

7. Identify the correct output: [1]


trip='KuwaitGoaMumbaiDubai'
print(len(trip.partition('Goa')))
a) 4 b) 2 c) 3 d) Error

8. Identify the correct output: [1]


day='Wednesday'
print(day.index('E'))
a) 1 b) 4 c) -8 d) Error

9. Rewrite the program after removing all the errors. Underline the corrections. [2]
numlist=[] numlist=[]
for x in range(1:11): for x in range(1,11):
num=eval(input('Value? ') num=eval(input('Value? '))
numlist+=num numlist+=[num]
print(sum(nlist)) print(sum(numlist))
Page 1/3
Class XI Second Term Computer Science Weekly Test 2022-23 Marking Scheme
10. Give the output of the Python program given below: [1]
weekend='FRIDAY-SATURDAY'
YRAYI
print(weekend[::-3])
SATUR
print(weekend[-8:12])

11. After the execution of Python program given below, what will be the correct output(s)? What will be
the maximum value and minimum value stored in the variable index? [2]
from random import randint
Possible correct outputs
vowels=['Ae', 'Uu', 'Ee', 'Oo', 'Ii']
a) EeOoIi b) UuEeOo
for x in range(2, 5):
index=randint(1, x) index Min: 1
print(vowels[index],end='') index Max: 4
a) EeOoIi b) UuEeOo c) IiOoEe d) EeAaIi

12. Give the output of the Python program given below: [2]
mylist=[123, 234, 345, 456] 135
for k in range(len(mylist)): 257
mylist[k]+=mylist[k]//10 379
for num in mylist: 501
print(num)

13. Write a Python program to input a string. Obtain a new string by toggling the case of letters
(uppercase to lowercase and vice-versa) present in the inputted string. Display the converted string.
You are only allowed to use input(), print(), chr() and ord(). [4]
Suppose inputted string contains 'GH-14/873 PASCHIM ViHaR'
The new toggled string should be 'gh-14/873 paschim vIhAr'
mystr=input('Input a string? ')
newstr=""
for ch in mystr:
if 'A'<=ch<='Z': ch=chr(ord(ch)+32)
elif 'a'<=ch<='z': ch=chr(ord(ch)-32)
newstr+=ch
print('Toggled String=', newstr)

14. Write a Python program to input a string. Check whether the inputted string is a Palindrome or not.
A Palindrome string reads same from left to right and right to left. You are only allowed to use
input() and print() functions.
[3]
mystr=input('Input a string? ')
newstr=""
for ch in mystr:
newstr=ch+newstr
if mystr==newstr:
print(mystr, 'Palindrome')
else:
print(mystr, 'Not Palindrome')

15. Write a Python program to create a tuple by inputting n (n is a user inputted value) floating point
values from the keyboard during the run-time. Calculate and display harmonic mean of floating
point values present in the tuple. You are only allowed to use input(), print() and len() functions.
[4]
If inputted values contained in the tuple are 1.2, 6.3, 4.4, 3.7, 2.8 then the Harmonic mean is

Page 2/3
Class XI Second Term Computer Science Weekly Test 2022-23 Marking Scheme
5
=1.85
1 1 1 1 1
+ + + +
1.2 6.3 4.4 3.7 2.8
n=int(input('Input Number of values? '))
nlist=()
for x in range(n):
val=eval(input('Input a value? '))
nlist+=(val,)
s=0
for num in nlist:
s+=1/num
hm=n/s
print('Harmonic Mean=', hm)

16. Write a Python program to create a list with n 4-digit random integer values, where n is a user
inputted value. Calculate and display the sum and average of elements which are neither divisible 3
nor divisible by 5. You are only allowed to use functions from random module, input() and print().
[4]
from random import randint
n=int(input('Input Number of values? '))
alist=[randint(1000,9999) for x in range(n)]
s=c=0
for num in alist:
if num%3!=0 and num%5!=0:
s+=num
c+=1
avg=s/c
print('Sum=', s)
print('Average=', avg)

Page 3/3

You might also like