SAMPLE PAPER-VI Class XI (Computer Science) Periodic Test-I
SUBJECT - COMPUTER SCIENCE
PERIODIC TEST - 1
Time : 1 Hrs 30 Mins Max marks : 50
Class : XI
Instructions :
All Questions are compulsory.
(1) Python is compiler or interpreter ? What are the two modes to use Python interpreter? 2
Ans : Interpreter.
Two Modes 1. Interactive mode 2. Script mode
(1 mark for each correct way)
(2) Write mutable data types used in Python. 1
Ans: 1. List 2. Dictionary
(3) Strings in Python are mutable or immutable ? 1
Ans: Immutable
(4) Write a program that asks two numbers stored in num1 and num2 also sum them. 2
num1 = input(“Enter First Num : ”)
num2 = input(“Enter Second Num : “)
print(‘Sum of two numbers = ’,num1+num2)
(1/2 marks for each input statement and 1 mark for correct print statement. Print statement syntax
may differ for different python versions)
(5) Write any four features of Python. 2
Ans: 1. It is platform independent
2. Used as both scientific and non-scientific programming language
3. It is open source language.
4. It is extensible language.
5. It has very vast library of add-on modules.
(1/2 marks for each correct feature for any four features)
(6) What are identifiers ? Write the rules for naming an identifier. 2
Ans: Identifiers in Python are not container these are just memory references
Rules : 1. Identifiers may have letters A-Z, a-z, numbers 0-9 and _ (underscore).
2. Must begin with a letter or underscore but not with digit.
3. keyword can not be used as identifier.
4. it is case sensitive i.e. upper case letters and lower case letters are different.
(1/2 marks for each correct rule any four rules)
(7) Show multiple assignments in Python. 1
Ans : a=b=c=10
(8) What if floor division operator ? What is difference between A/4 and A//4 if A=8.8 1
Ans : Floor division operator truncates fractional part and gives result only whole part.
A/4=2.2 while A//4=2.0
(9) Write output of the following : 1
>> a=10
>> b=10
>> a is b
Ans : True
(10) What will be the output of the following expression ? (5<10) and (10<5) or(3<18) and not 8<18 2
Ans : False
(11) What is type casting ? Give example. 2
Ans : The explicit conversion of an operand to a specific type is called type casting.
A=12
D=float(A)
(12) What is if-elif-else statement in python ? Give Example. 4
Ans: To serve conditions for compound statements if-elif statement is used.
If c==1
print(‘Monday’)
elif c==2
print(‘Tuesday’)
elif c==3
print(‘Wednesday’)
elif c==4
print(‘Thursday’)
elif c==5
print(‘Friday’)
elif c==6
print(‘Saturday’)
elif c==7
print(‘Sunday’)
else
print(‘Wrong Selection’)
(13). Write a program for sum of all even and odd integers of first n natural numbers. 3
Ans: n=int(input(“Enter limit of tne natural number : ”)
ev=odd=0
i=1
while i<=n :
if i%2==0 :
ev+=i
else :
odd+=i
i+=1
print(“Sum of all even numbers up to limit ”,n,”=”,ev)
print(“Sum of all odd numbers up to limit ”,n,”=”,odd)
(14). Find output of the following codes : 2
If 4+5==10:
print(“TRUE”)
else :
print(“FALSE”)
print(“TRUE”)
ANS : FALSE
TRUE
(15). Write code for the following : 4
4321
432
43
4
ANS :
for i in range(4)
for j in range(4,i,-1)
print(j,end=’ ’)
(16). Write a program to print Fibonacci series first 20 elements.Some initial elements are as : 5
0,1,1,2,3,5,8………
Ans : first=0
second=1
print(first)
print(second)
for a in range(1,19)
third=first+second
print(third)
first,second=second,third
(17).Write a python program for the series calculation : 5
S=(1)+ (1+2)+ (1+2+3)+ (1+2+3+4)+………n terms
Ans :
s=0
n=int(input(“How many terms..”)
for i in range(1,n):
t=0
for j in range (i)
t=t+j
print(t)
s=s+t
print(“SUM = ”,s)