You are on page 1of 3

ARMY PUBLIC SCHOOL, RANIKHET

CLASS-XI
COMPUTER SCIENCE
HALF YEARLY EXAMINATION-2020
MM:70 TIME: 03 HRS

GENERAL INSTRUCTIONS:

 Programming language ‘python’


 Avoid cutting and erasing
 If you re-answer any question, cancel the previous answer.

Q1(a). Write and explain break and continue statements with the help of suitable examples. [2]

(b) What will be the output: [2]

import random
import math
print(math.ceil(random.random()))

(c) Write different loop constructs used in python. Also compare their usage. [2]

(d) Write the output of following python code: [2]

x=1237896

s=0

while x:

s=s+x%10

x=int(x/10)

print( s)

(e) Which of the following is an invalid variable? [1]

(i) my_day_2 (ii) 2nd_day (iii) Day_two (iv) _2

(f) Evaluate the value of Y, if A=16 and B=15: [1]

Y=A%B//A

(g) Predict the output of the following python code: [2]

word="green vegetables"
print(word.find('g',2))
print(word.find('g',2))
print(word.find('g',2))
(h) Write the output of the following python code: [2]
text="yahooMail."
l=len(text)
ntext=""
for i in range(0,l):
if text[i].isupper():
ntet=ntext+text[i].lower()
elif text[i].isalpha():
ntext=ntext+text[i].upper()
else:
ntext=ntext+'#'
print(ntext)

(i) Suppose L=”Ranikhet”, predict the output of the followings: [2]


L ="Ranikhet"
print(L[0:])
print(L[3:])
print(L[::2])
print(ord(L[0]))

[j] Identify the type of tokens from the followings: [2]

for, “Ranikhet”, 123, Roll_No, if, //, **, age, break

Q2.(a) Write a python program to check for a Armstrong Number. [3]


(b) WAP to print the LCM and GCD of any two given numbers [3]
(c) WAP to find the sum of given series: [3]
1+x2/2! -x3/3!+………xn/n!
(d) WAP to input a decimal number and converts it into Hexadecimal. [3]
(e) WAP to calculate and print the sum of all even numbers and sum of all odd numbers
between 1 to N. [3]

Q3. (a) WAP that accepts a string as a parameter and counts total vowels and consonants in the given
string. [3]
(b) WAP that takes a string as a function parameter and removes every vowel character from the
given string. [3]
If Original string is:” We are learning python”
New string is: “W r lrnng pythn”
(c) Write a Program that takes a string from the user and counts total words in the string beginning
with vowels.
X=”My umbrella is lost today in the school. All students offered me for the for their umbrella
sharing” [3]
Total Words are:6
(d) Write a python function that takes a string and searches for the existence of any given word in the
string. [3]
X=”Army Public School Ranikhet”
If Given Word is = “Public” the program should print Found……message.
(e) Write a program to input a password and checks whether the given password is Strong or Weak.
The Strong Password must be at least 8 Char long and must be the combination of a Upper Case,
Lower Case, Digit and a Special Character. [3]

Q4(a). What is a comment in programming? Explain different types of comments in python. [2]
(b) Define Keywords with the help of suitable example. [2]
(c) What is type casting? Write an Expression to explain the use of type casting. [2]
(d) What is the meaning of Data Type? Write the Difference between Mutable and Immutable Data
Types in python with the help of their examples. [2]
(e) What is Identifier? Explain with the help of example. [2]

Q5.(a) Write a program to print the following string triangle: [3]


R
RA
RAN
RANI
RANIK
RANIKH
RANIKHE
RANIKHET

(b) Write a program to print following number triangle: [3]


1
2 3
3 4 5
4 5 6 7

(c) Write a python Program to print a Fibonacci Series upto N terms. [2]
(d) Write a Program to check for a leap year. [2]
(e) Write a program to find the sum of given series: [2]
1+1/22 – 1/33 + 1/44- …………………….1/nn

You might also like