sumita arora Questions : Class XI Computer Science/ IP
Getting Started with Python
1 Who has developed Python programming Language? In which year it was developed? 1
2 On what basis python has been named? 1
3 Explain any three merits of Python. 3
4 Explain any three demerits of Python. 3
5 Why Python is called a cross-platform language? 1
6 Give full form of Python’s IDLE. 1
7 What do you mean by IDE? Explain. 2
8 Name a few Python IDEs. 2
9 Why Python is called an interpreted language? 1
Python Fundamentals
1 Does Python support UNICODE? 1
2 What are tokens? List all tokens in Python. 2
3 What are keywords? Explain. List a few keywords available in Python. 2
4 What do you mean by identifiers? Give any four rules to define an identifier. 3
5 What are literals? List all literals in Python. 2
6 How do you form string literals in Python? 1
7 Explain how you can use single line and multiline strings in Python. 2
8 What do you mean by complex literal? How will you write a complex value, explain with an 2
example?
9 How can you write a floating point value using exponent form? Give an example. 1
10 List Boolean literal? 1
11 What is “None”? 1
12 What do you mean by comments? How will you add inline, single line or multiline comments 2
in Python?
13 What is a block in python? How is a block created in Python, explain with example? 2
14 How many spaces are used to define an indentation level? 1
15 Define variable in Python? How a variable does created? 2
16 What will happen if variable holding a value of integer type assigned another value of string 1
type?
17 What do you mean by lvalue and rvalue? Give an example. 2
18 Give an example each of following: 1
i. Assigning same value to multiple variables.
ii. Assigning multiple values to multiple variables.
19 What is dynamic typing? (datatyping) 1
20 Explain the use of input() function with an example. 2
21 What type value is returned by input() function? If the integer or float values are to be input 2
write an example statement how will you use input() function?
22 Explain with example how to use print() function to:
i. Print Single string or variable’s value. 1
ii. Print multiple strings or variable’s value or combination of both. 1
iii. Specify the separator in between multiple output strings. 1
iv. Specify end character after string output. 1
23 Consider following code: 1
print(“Kendriya”)
print(“Vidyalaya”)
its current output is :
Kendriya
Vidyalaya
1
Modify only one line of the above code to print “Kendriya Vidyalaya” in same line.
24 Identify the types of following literals: 3
i. 23.789
ii. False
iii. “True”
iv. 34.71E-4
v. None
vi. 4+3j
25 Identify valid or invalid identifiers: 3
i. True
ii. Student-Name
iii. IF
iv. PRINT
v. 1stAge
vi. Number1
26 Find out the error in following code: 1
Salary= input(“Salary :”)
Bonus=10/100 * Salary
Print (“Bonus”, Bonus)
27 Find out the error in following code: 1
Name=input (“What is your Name”)
print(“Hi”,Name)
28 What will be the output of following code : 2
a, b = 10, 2
a, b, a= a +5, b+2, a+4
print(a, b)
29 What will be the output of following code:
2
print("Hi", "Manoj!","Good Morning", sep="#", end="$$>")
print("its", "a pleasant day.")
print("Do something good for society")
30 Find the error in the following code: 1
print(“Current GDP of India is =”, GDP)
31 State with justification whether following code contains any error (if Hindi text is in Unicode): 1
print(“ये हमारा केन्द्रीय विद्यालय है ”)
Data Handling
1 What are the core data types in Python?
2 Explain Boolean and complex data types with example. 2
3 Write the output of following code 2
DValue= 3.59 + 4j
DValue += 2 + 4j
print(DValue.real)
print(DValue.imag)
4 Following code has one error, identify the error and explain the reason: 1
Word= “Nagpur”
Word[3]=’K’
5 “Strings are not mutable”. Explain. 1
6 Do you agree that “Individual characters of a string can be accessed by using negative index”? 2
If yes than explain how?
7 Compare strings, lists and tuples. 3
2
8 How does dictionary different than strings, lists, and tuples? 2
10 What are mutable and immutable data types? Classify the data type available in python in 3
mutable and immutable categories.
11 How will you identify the type of a variable in a Python program? Explain with an example. 2
12 What is the id of an object in Python? How can you identify the id of an object explain with 3
an example.
13 “If the IDs of two objects are same than they must have same value, but if any two objects 3
have same value they may not have same ID”. Explain with an example.
14 Write an example program where two string having same values have different IDs. 2
15 What will be value of x after evaluation of each of following separately: 2
i. x = 29 / 5
ii. x = 39 // 4 * 2
iii. x = 3 ** 2 ** 2
iv. x = 2 ** 5 % 3 -5
16 How will you identify that two objects have same ids without using == operator. Explain with 2
example.
17 Differentiate equality (==) and identity (is) operators with example. 2
18 What do you mean by chained comparison operators? Explain with example. 3
19 What do you mean by precedence of operators? Explain with example. 2
20 What do you mean by associativity of operators? Explain with example. 2
21 List operators which have right to left associativity in Python. 1
22 Which operators are used make decisions after combining multiple conditions? What do you 2
call such operators? Give names of these operators.
23 What will be the type of final evaluated value of following expressions: 2
i. print (type (5*2))
ii. print (type (3 * 32 // 16))
iii. print (type (14 * 5.0 *2))
iv. print (type (50/2 + 5))
24 What will be the final output of following logical expression : 2
(17 >4) or (3<5 ) and not (3< 2) and not 17 < 18
25 What do you mean by implicit type conversion? Explain with an example. 2
26 What do you mean by type casting? Explain with example. 2
27 What functions are available in Python for type casting? Explain. 2
28 Identify the data type of rvalue of following: 2
i. X= “Great India”
ii. Y= { 1: “Monday”, 3: “Wednesday”, 5: “Friday”, 7: “Sunday” }
iii. Z= (“a”,”e”, “i”, “o”, “u”)
iv. W= [“Rakesh”, “Rajesh”, “Ravindra”, “Pawan”, “Santosh”]
29 Identify each of the following whether mutable and immutable : 2
i. X= “Great India”
ii. Y= { 1: “Monday”, 3: “Wednesday”, 5: “Friday”, 7: “Sunday” }
iii. Z= [“a”,”e”, “i”, “o”, “u”]
iv. W= (“Rakesh”, “Rajesh”, “Ravindra”, “Pawan”, “Santosh”)
30 Why is Boolean considered a subtype of integer? 2
31 How to use math module in Python script? 1
32 Explain the use of following math library functions available in Python with example (any 4
two):
i. ceil()
ii. sqrt()
3
iii. floor()
iv. log()
v. pow()
33 Explain the use of following math library constants with syntax and example: 2
i. pi
ii. e
34 What will be the output of following code: 2
A= 3 + int (5/2)
B= A/2
print( A, B)
35 What will be the output of following code: 2
A=True
B= 0<5
print(A==B)
print (A is B)
Conditional and Iterative Statements
1 Explain following with syntax and example:
i. Empty Statement 2
ii. Simple Statement 2
iii. Compound Statement 2
2 Differentiate Selection and iteration. 2
3 Explain algorithm. 1
4 Explain flowcharts with its major symbols. 2
5 Explain Pseudocode with example. 2
6 Explain Decision Trees with example. 2
7 An organization wants to give its employees bonus based on following conditions:
if the employee is male
bonus will be 10 % of salary where salary is less than 50000 otherwise
bonus will be 15 %
if the employee is female
bonus will be 20 % of salary where salary is less than 50000 otherwise
bonus will be 25 %
Develop following for to calculate bonus:
i. Algorithm 2
ii. Flow Chart 2
iii. Pseudocode 2
iv. Decision Tree (to deal make the decision about bonus calculation) 2
8 Explain if...else statement with syntax and example. 3
9 Explain if…elif statement with syntax and example. 3
10 Write a program to find out the largest number out of given three numbers. 3
11 Write a program to calculate simple interest using formula SI=P*R*T/100. Rate will be 5% if 3
the principal amount is less than 25000 otherwise rate will be 8 %.
12 Write a program to find out whether a given year is leap year. 2
13 Write a program to find out whether a number is odd or even. 2
14 Write a program to calculate bonus for employees based on following conditions: 3
if the employee is male
bonus will be 10 % of salary where salary is less than 50000 otherwise
bonus will be 15 %
if the employee is female
4
bonus will be 20 % of salary where salary is less than 50000 otherwise
bonus will be 25 %
15 Write a program to calculate and print the roots of quadratic equation ax2+bx+c=0. The 4
program should display suitable message whether roots are real, equal, different or imaginary.
16 Write a program to accept an integer and display the corresponding day of week i.e. 1 for 3
Monday, 2 for Tuesday and so on. If the number is not in 1 to 7 it should display a message
“Invalid Day Number”.
17 Write a program to find out the grade of student based on his obtained percent as per following 4
conditions:
Percent Grade
<33 F
33 to 44 E
45 to 59 D
60 to 74 C
75 to 89 B
90 and above A
18 Write a program to calculate electricity charges based on number of consumed electricity units 4
as per following conditions:
Units Charges
Upto 100 Rs. 2 per unit
101 - 200 Rs. 200 + Rs. 3.5 per unit for units exceeding 100
201 - 300 Rs. 550 + Rs. 7.5 per unit for units exceeding 200
301 & above Rs. 1300 + Rs. 9 per unit for units exceeding 300
19 Write a program to print whether a given character is an uppercase or a lowercase letter or a 3
digit or any other character.
20 Write a program to input three angles and determine if they form a triangle or not. (Hint : sum 2
a triangles all three angle is 180)
21 Write a program to calculate BMI of a person after inputting its weight in kgs and height in 3
meters and then print the nutritional status as per following table :
Nutritional Status WHO criteria BMI cut-off
Underweight less than 18.5
Normal 18.5 to 24.9
Overweight 25 – 29.9
Obese 30 or above
Formula to calculate BMI = weight in Kgms./ (height in meter)2
22 Explain with example one advantage of using if…elif statement over using if statement multiple 2
times.
23 Write a program to arrange three numbers in ascending order. 3
24 Rewrite the following code after removing errors. Underline each correction. 2
smonth = int (input (“Please enter name of a month”))
if smonth= “January” :
print(“Beginning of the Year”)
elif (smonth==“April”) :
print(“Beginning of Financial Year”)
elif (smonth==”July”)
print(“Begnning of acadmic activities in colleges”)
25 Rewrite the following code after removing errors. Underline each correction. 2
If n==0
print(“Zero”)
5
elif : n==1
print(“One”)
elif
n==2
print(“Two”)
else n == 3
print(“Three”)
26 What is a loop? 1
27 What is range() function? Explain with syntax and example. 2
28 Explain operators in and not in with example. 2
29 Differentiate counting and conditional loops. Give the names of one conditional loop and one 3
counting loop available in Python.
30 Explain for loop with syntax and example. 3
31 Write a program to print table of a given number. 2
32 Explain while loop with syntax and example. 3
33 Explain break statement with syntax and example. 2
34 Explain continue statement with syntax and example. 2
35 Explain loop’s else statement used with syntax and example. 2
36 What do you mean by named conditions or stored conditions explain with example. 3
37 Write a program to find out the value of Xy . 3
38 Write a program to find the value of X!.(Factorial of X) 3
39 Write a program to find out the largest number out of given n numbers. 3
40 Write a program to find out the sum of first n terms of following series: 4
1 + X + X2 + X3 + X4 + ………………..+ Xn-1
41 Write a program to find out the sum of first n terms of following series: 4
1-X+ X2 - X3 + X4 - ………………..(+|-) Xn-1
43 Write a program to find out the sum of first n terms of following series: 4
1 + X + X2 / 2! + X3 / 3! + X4 / 4! + ………………..+ Xn-1 / (n-1)!
44 Write a program to find out the sum of first n terms of following series: 4
1 - X + X2 / 2! - X3 / 3! + X4 / 4! - ………………..(+|-) Xn-1 / (n-1)!
45 Write a program to print the n terms of Fibonacci series: 3
0 1 1 2 3 5 8 13 21 …..
46 Write a program to print the following pattern (using only one * in a print statement) 3
*
**
***
****
*****
47 Write a program to print the following pattern (using only one * in a print statement) 3
*****
****
***
**
*
48 Write a program to print the following pattern (print only one value at a time) 3
1
2 3
4 5 6
7 8 9 10
11 12 13 14 15
6
49 Write a program to find out whether it is a prime number or not. 4
50 Write a program to find out the reverse of a given number. 4
51 Write a program to find whether a number is palindrome. (A palindrome is a number that is 4
same of its reverse)
52 Write a program to count the number of digits in a given number. 4
53 Write a program to find the sum of all digits of a given number. 4
54 Write a program to find the sum of all even digits and odd digits separately. 4
55 Write a program to print first 10 Mersenne numbers. (Mersenne number are in the form of 3
(2n-1) )
56 Write a program to find the LCM of three integers. 3
57 Write a program to find the HCF of three integers. 3
58 Rewrite the following code fragment that saves on the number of comparisons: 3
if(a==0):
print(“Zero”)
if (a==1):
print(“One”)
if(a==2):
print(“Two”)
if(a==”Three”):
print(“Three”)
57 Rewrite the following code fragment remove and operator and use chaining of comparison 3
operators. Logic of program should not change.
if(score <33 ):
grade= “F”
if(score >=33 and score < 45 ):
grade= “E”
if(score >=45 and score < 60 ):
grade= “D”
if(score >=60 and score <75 ):
grade= “C”
if(score >=75 and score <90 ):
grade= “B”
if(score >= 90 ):
grade= “A”
print (grade)
58 What will be the output of the following code if the input is 3 2
n = int ( input( “Enter an integer “))
if n < 1 :
print(“invalid value”)
else :
for i in range(1,n+1) :
print( i * i)
59 Rewrite the following code fragment using for loop: 2
num = 10
while num> 0:
sum += num
num -= 2
print( sum)
7
60 Predict the output of the following code if value of a is entered as 5: 3
a = int( input(“Enter break code “)) # line first
num = 10
while num> 0:
sum += num
num -= 2
if num < a :
break;
else :
sum+= num
print( sum)
61 Rewrite the following code fragment using while loop: 2
min = 0
max= num
if num < 0 :
min = num
max = 0
for i in range(min, max +1):
sum +=i
62 Rewrite the following code fragment using while loop : 2
for i in range( 1,16 ):
if i%3==0:
print (i)