HALF YEARLY PAPER
CLASS XI CS
M.TIME : 03HRS
M.MARKS:70
Q.1 (a)What is a cross –platform software? 1
(b)Write any two applications area of python programming? 2
(c)What is the difference between an expression and a statement in python? 2
(d)From the following, find out the valid identifier: 2
_abc_d, break, 1rak, doc14, a2bc5,_punc, ray.dat
(e)What are mutable datatypes in python? Give two examples 2
(f)What will be the output produced by following code fragment? 2
x, y= 20, 60
y, x, y=x, y-10, x+10
print (x, y)
(g)What is a comment in python? Give an example 1
(h)What are endless loops? Why do such loops occur? 1
Q.2 1
a) What will be the output of following Python code?
a=12
b=7.4
c=1
a-=b
print (a, b)
a*=2+c
b+=a*c
print( a)
(b) Write a pseudocode for checking if a number is a factor of 3215?. 2
( c) 3
Draw a flow chart to find largest of numbers.
d) Find errors in the following code fragments. 2
(i) print(X=5)
(ii) A=input(“Value”)
B = A/2
print(A,B)
Q.3 (a) Given three Boolean variables a, b, c as a = True, b = False and c = False. 3
Evaluate the following Boolean expression.
(i) not a and b
(ii) not (( not b or not a) and c)
(iii) (a and b) or not c
(b) Write a program to check whether square root of a number is prime or not. 3
(c) Rewrite the following code fragment using for loop: 1
i=100;
while (i>0):
print (i)
i-=3
(d)Evaluate and justify 3
I. 0 or None and “or”
II. 1 or None and ‘a’ or’b’
III. False and 23
IV. 23 and False
V. Not(1==1 and 0!= 1)
VI. “abc”==”Abc” and not (2==3 or 3==4)
Q.4 (a) Consider the following program: 2
N = int(input(“Enter N”))
I=1
Sum = 0
while I<N:
if( I%2 == 0):
Sum = Sum + I
I=I+1
print(Sum)
(i) What is the output when the input value is 5?
(ii) What is the output when the input value is 0?
( b) Write a program that reads a string and checks whether it is a palindrome string 3
or not.
(c)Write python expression for the following: 2
(d) Evaluate the following expression: 2
(i) 50 / (5 - ( 3 + 2)) or 3 < 5
(ii) ( 3 % 4 == 0) and (500 % 100 != 0)
(e) 1
What is the use of try…except block in python?
Q.5 (a) Find the output of the following python code: 1
a, b, c = 2, 3, 4
a, b, c = a*a, a*b, a*c
print(a,b,c)
(b) Write a Python script to print Fibbonacci series first 20 elements. Some initial 1
elements of a Fibbonacci series are: 3
0 1 1 2 3 5 8 …….
(c ) Differentiate between syntax errors and run time errors in python 1
(d) Identify the errors in the following code: 2 2
i. L1 = [1,2,3,5] ii. L1 = [1,3,5,8]
An = L1.remove(7) An = L1.remove(8)
print(An + 2)
(e) Find out the output of following code segment: 2
numlist = [2,5,2,3,6,6,9]
pos=0
odds=evens=0
length=len(numlist)
while pos<length:
if numlist[pos]%2==0:
evens=evens+1
else:
odds=odds+1
pos=pos+1
if odds>evens:
print(“Balanced oddity”)
Q.6 (a) How are tuples different from list when both are sequences? Illustrate with an 2
example
(b) Write a program using loop that asks the user to enter an even number. If the 2
number entered is not even then display an appropriate message and ask them to
enter a number again. Do not stop until an even number is entered. Print a
Congratulatory message at end.
(c) Write a Python function SecondLargest(T) which takes as input a Tuple T and 3
returns the second largest element in the tuple.
(d)Give the output of the following: 1
i=0
while i < 4:
print (L1 [i], ‘,’, end=’ ‘ )
i+=1
(e) 2
Write the output from the following code:
A=[2,4,6,8,10]
L=len(L)
S=0
for I in range(1,L,2):
S+=A[I]
print( “Sum=”,S )
Q.7 (a)Predict the output of the following code- 2
d1={5:"number","a":"string",(1,2):"tuple"}
print("Dictionary contents")
for x in d1.keys():
print(x,':',d1[x],end=' ')
print(d1[x]*3)
print()
What type of objects can be used as keys in dictionaries? Also explain why? 1
(c ) Write a Python script to generate and print a dictionary that contains a 2
number (between 1 and n) in the form (x, x*x).
(d ) Write a program to sort list using Bubble sort. 4
(e )Draw a state transition diagram, for operation of an ATM machine. 1
(f)Differentiate between pop() and remove () functions of list with an example. 2