You are on page 1of 3

HALF YEARLY EXAMINATION 2022

CLASS XI
COMPUTER SCIENCE

TIME: 3 HRS TOTAL: 70

1) A. Consider the following code: (4)


string=input("enter a string:")
while True:
if string[0]=='a':
string=string[2:]
elif string[-1]=='b':
string=string[:2]
else:
break
print(string)
What will be the output produced, if the input is is : (i) aabbcc (ii) aaccbb (iii) abcc?
B. Write a program that takes a string with multiple words and then capitalizes the first
letter of each word and forms a new string. (4)
C. Write Python script to print the following pattern: (4)
1
13
135
1357

OR

Write a program that takes an input from user and checks whether the number is prime
or not? (4)

2) A. Consider the following code and find the errors. (2)


num = input("Enter a number: ")
if (num % 2) = 0:
print(num," is Even")
else:
print(num," is Odd")

B. Write a Python program to find the factorial of a given number. (4)

(Example: If 6 is the input then the output is 720)

C. Write a Python program to print Fibonacci series’ first 8 elements. (4)

( Fibonacci series : 0 1 1 2 3 5)
D. Consider the following code and find the errors: (2)

lower = 900
upper = 1000
print("Prime numbers between",lower,"and",upper,"are:")
for num in range(lower,upper + 1):
if num > 1
for i in range(2,num):
if (num % i) == 0:
break()
else:
print(num)
3) A. What are endless / Infinite Loops? Give an Example. (2)
B. Write a program to find sum of the series:
2 3 4 n
s=1+ x + x + x + x …..+ x (4)
C. What is the difference between identifiers and keywords? (3)
D. How to create multiline string in python. Example. (1)
E. Write down the difference between Compiler and Interpreter. (2)
4) A. Find the output of the following code: (3)
num = 12
for i in range(1, 11):
print(num,'x',i,'=',num*i)
B. Find the error/Errors from the following code: (4)

string1=raw_input("Enter first string:")


string2=raw_input("Enter second string:")
count1=0
count2=0
for i in string1:
count1=count1+1
for j in string2:
count2=count2+1
if(count1<count2):
print("Larger string is:")
print(string2)
elif(count1==count2):
print("Both strings are equal.")
else:
print("Larger string is:")
print(string1)
C. Write down the types of strings that Python supports. (2)
D. What is None Literals in Python? (2)
E. Convert 101101002 to its octal form.
(1)
5) A. Prove De-Morgan’s Theorem using Truth Table. (4)
B. Draw the Boolean expression using Logic gates: ( A+ B ) (C + D)C (4)
C. Draw the Boolean Expression using Logic Gates: A+ BC + D (4)
6) A. Which Boolean Law is the following: (4)
A+BC= (A+B)(A+C)
Prove it using truth table.
B. Draw the Boolean expression using Logic gates: AB+ AC (4)
C. Write the types of software and give one example each. (2)

You might also like