11 CSWTOct 2022 SQP
11 CSWTOct 2022 SQP
4. Identify the expression that checks single character string variable ch contains an alphabet. [1]
a) 'A'<=ch<='z'
b) 'a'<=ch<='z' or 'A'<=ch<='Z'
c) A<=ch<=Z or a<=ch<=z
d) ch>='A' and ch<='Z' and ch>='a' and ch<='z'
8. Rewrite the complete Python script after removing all the errors: [2]
n=eval('Input an integer? ')
if n==0
print(n, 'Zero')
elif n>0:
print(n, Positive)
else n<0:
print(n, 'Negative')
9. Suppose number is a variable containing a positive value. Write all the possible Python statements to
display number4. [2]
10. With suitable examples write two differences between run-time error and logical error. [2]
Page 1 / 3
Class XI First Term Computer Science Weekly Test 2022-23 Sample Question Paper
11. What will be the output of following code [3]
x, y, z=2, 3, 5
x*=y+z
y*=z+x
z*=x+y
print(x, y, z)
x+=x+y+z
y+=x+y+z
z+=x+y+z
print(x, y, z)
12. Write a Python script to input Roll Number (integer), Student Name (string), Theory Marks (float -
out of 70), Practical Marks (float - out of 30) and Weekly Test marks (float - out of 80). Calculate
Term total as Theory Marks + Practical Marks and Grand Total as 80% of Term total + 25% of
Weekly test. Display all the values stored in all the variables on the screen.
[3]
roll=int(input('Roll? '))
name=input('Name? ')
theo=float(input('Theory [0-70]? '))
prac=float(input('Practical [0-30]? '))
wtest=float(input('Weekly Test [0-80]? '))
ttot=theo+prac
gtot=0.80*ttot+0.25*wtest
print('Roll=',roll)
print('Name=',name)
print('Theory Marks=',theo)
print('Practical Marks=',prac)
print('Weekly Test Marks=',wtest)
print('Term Total=',ttot)
print('Grand Total=',gtot)
13. Write a Python script to input a single character string. If the inputted string contains single
character, then toggle the case of an alphabetic character (uppercase converted to lowercase and
vice-versa). If the string contains more than one characters or does not contain any character, then
display an appropriate message. Don't use any string methods.
[3]
ch=input('Input a single character? ')
if len(ch)==1:
if 'A'<=ch<='Z': #if ch>='A' and ch<='Z':
ch=chr(ord(ch)+32)
elif 'a'<=ch<='z': #if ch>='a' and ch<='z':
ch=chr(ord(ch)-32)
print(ch)
else:
print('Invalid Input!')
14. Write a Python script to input name, telephone number and number of telephone calls in a month.
Calculate amount due based on the table given below:
Number of Calls Amount due
<=100 Telephone rent
>100 and <=300 Telephone rent + Rs 1.25 * (number calls - 100)
>300 and <=600 Telephone rent + 250 + Rs. 1.50 * (number calls - 300)
>600 Telephone rent + 700 + Rs. 1.75 * (number calls - 600)
Page 2 / 3
Class XI First Term Computer Science Weekly Test 2022-23 Sample Question Paper
Telephone rent is Rs. 200 per month. Display the name, the telephone number, number of calls and
amount due on the screen. [3]
name=input('Name? ')
tele=int(input('Telephone Number? '))
call=int(input('Number of Calls? '))
if call<=100: amtdue=200
elif 100<call<=300: amtdue=200+1.25*(call-100)
elif 300<call<=600: amtdue=450+1.50*(call-300)
elif call>600: amtdue=900+1.75*(call-600)
print('Name=',name)
print('Telephone Number=',tele)
print('Number of Calls=',call)
print('Amount Due=',amtdue)
15. Write a Python script to input an integer n; find the sum of the series given below and display the
sum on the screen:
53+103+153+…+(5n-5)3+(5n)3 [3]
n=int(input('Input an integer? n=int(input('Input an integer?
')) '))
k, s=5, 0 k, s=1, 0
while k<=5*n: while k<=n:
print(k**3) #optional t=5*k
s+=k**3 print(t**3) #optional
k+=5 s+=t**3
print('Sum=', s) k+=1
print('Sum=', s)
Page 3 / 3