You are on page 1of 59

1

COMPUTER SCIENCE
(Python)
ASSIGNMENT
CLASS XI
2021-22
. CONTENTS .

S. NO TOPICS PAGE NO.

I. MACRO PLANNER 3

II. Unit 1: Computer Systems and Organization 4-9


1. Computer Fundamentals 4-5
2. Boolean algebra 6-8
3. Data representation (Number System) 9

III. Unit 2: Programming and Computational Thinking 10-33


1. Introduction 10-18
2. Conditional statements 18-23
3. Iterative statements 23-27
4. Flowcharts, Algorithms 27
5. Lists, Tuples and Dictionaries 28-33

IV. Unit 3: Society, Laws & Ethics 33-34

V. Question Paper of previous session 2020-21 35-37

COMPUTER SCIENCE CLASS - XI -2-


MACRO PLANNER

CYCLE TEST 1
Unit 1: Computer Systems and Organisation 10
Unit1: Number System 20
TOTAL 30

CYCLE TEST 2
30
TOTAL 30

TERMINAL 1
Unit 1: Computer Systems and Organisation 10
Unit 2: Programming and Computational Thinking 25
TOTAL 35

CYCLE TEST 3

TOTAL 30

ANNUAL : THEORY
Unit 1: Computer Systems and Organisation 20
Unit 3: Society, Laws & Ethics 15
TOTAL 35

ANNUAL : PRACTICAL
PYTHON PROGRAM 1 (WRITE:5 & EXECUTE: 5) 10
PYTHON PROGRAM 2 (WRITE: 5 & EXECUTE: 5) 10
VIVA 05
PRACTICAL FILE 05
TOTAL 30

COMPUTER SCIENCE CLASS - XI -3-


Unit 1: Computer Systems and Organization

Computer Fundamentals

Q-1. What is booting?                                               

Q-2. Name two GUI and text based operating systems.                                    

Q-3. Give a difference between each of the following:

a. RAM and ROM

b. Primary Memory and Secondary Memory

Q-4. Explain the device and file management functions of an operating


system in short.   

Q-5.    Explain GUI and distributive operating system.                                          

Q-6.  Give one difference between compiler and interpreter. Name two
softwares based on compiler.

Q-7.   What is application software? Give two examples.                                       

Q-8.   What is an assembler?                                                                               

Q-9. What is an operating system? Give the names of 2 popular operating


systems.           

Q-10. Give two differences between Primary Memory and Secondary


Memory.                     

Q-11. How is utility software different from system software? Give a name of
each type of software.

Q-12.  Give two points of difference between the following:

a.      Compiler and interpreter

b.      RAM and ROM

c.       Application and Utility software

d.      Freeware and shareware

Q-13.   Determine the full form of the following terminologies:

a.      ASCII

b.      USB

COMPUTER SCIENCE CLASS - XI -4-


c.       RISC

d.      DVD

e.      UNICODE

f.        RAM

g.      EPIC

h.      GUI

i.        HDD

j.        ISCII

Q-14.   Define the following terminologies:

a.      Cache Memory

b.      Utility software

c.       System software

d.      Proprietary software

Q-15.   Explain any two functions of an operating system.                                     

Q-16.   What is cold and warm booting?

Q-17.   Explain the functions of an operating system.

Q-18.   Explain the types of operating system.

Q-19.   What do you understand by a 64-bit processor?    

COMPUTER SCIENCE CLASS - XI -5-


                                                                  

Unit 1: Computer Systems and Organization

Boolean Algebra

Q-1. State DeMorgan's Law. Verify one of the Demorgan’s Laws using truth
tables.

Q-2. Do as directed:

a. Write the equivalent Boolean expression for the following Logic Circuit:

b. Write the equivalent Boolean Expression for the following Logic


Circuit:                                                                                       

c. Write the equivalent Boolean Expression for the following Logic circuit :          

d. Write the equivalent Boolean Expression for the following Logic Circuit.          

e. Write the equivalent Boolean Expression for the following Logic Circuit.  

COMPUTER SCIENCE CLASS - XI -6-


f. Write the equivalent Boolean Expression for the following Logic Circuit.

g. Write the equivalent Boolean Expression for the following Logic Circuit.    

h. Write the equivalent Boolean Expression for the following Logic Circuit.     

i. Write the equivalent Boolean Expression F for the following circuit


diagram:                                                    

COMPUTER SCIENCE CLASS - XI -7-


j. Write the equivalent Boolean Expression for the following Logic Circuit.     

k. Draw a logical Circuit Diagram for the following Boolean Expressions:


A.(B+C’)

L. Draw the logic circuit for F=A.B' + C.D'

M. Represent the Boolean expression Y.Z+X.Z with a truth table and logic circuit.

COMPUTER SCIENCE CLASS - XI -8-


Unit 1: Computer Systems and Organization

Number System
 

Q. Perform the conversions for the following:

1. (102.5)8 = ( ? )2 = ( ? )10 = ( ? )16

2. (AB.E)16 = ( ? )2 = ( ?)8 = ( ? )10

3. (402.8)10 = ( ? )2 = ( ? )8 = ( ? )16

4. (100101.110)2 = ( ? )8 = ( ? )10 = ( ? )16

5. (9C.B)16 = ( ? )2 = ( ? )8 = ( ? )10

6. (197.75)10 = ( ? )2 = ( ? )8 = ( ? )16

7. (110110.101)2 = ( ? )8 = ( ? )10 = ( ? )16

8. (372.4)8 = ( ? )2 = ( ? )10 = ( ? )16

9. (101001.011)2 = ( ? )8 = ( ? )10 = ( ? )16

10.  (A9.D)16 = ( ? )2 = ( ? )8 = ( ? )10

COMPUTER SCIENCE CLASS - XI -9-


Unit 2: Programming and Computational Thinking (PCT-1)

Chapter 1: INTRODUCTION TO PYTHON

TYPE A: Theoretical Questions

Q-1. Reema confused between 3*2 and 3**2. Help her know the difference between
the two expressions.

Q-2. If a, b, c = 3, 2, 5 and you write an expression like F=a + bc + a*c, then what
error will it produce? Write the correct expression.

Q-3. How do we convert a string to a number in Python?

Q-4. How can you know the data type of a variable?

Q-5. What is a variable?

Q-6. How can we declare variables in Python?

Q-7. What is a dynamic type?

Q-8. Name the key attributes of a Python object.

Q-9. Write an example explaining multiple assignments.

Q-10. Name five primitive data types in Python.

Q-11. What are the differences between single quotes, double quotes and triple
quotes?

Q-12. State the basic rules to declare variables in Python.

Q-13. When does a logical ‘AND’ operator produce a ‘TRUE’ result?

Q-14. How can you alter the order of evaluation of operators?

Q-15. Explain unary and binary operators with examples.

Q-16. Differentiate between division operator (/) and floor division operator (//).

Q-17. What is the difference between:


num=10 and num == 10?

Q-18. What does the following (‘a’ < ’b’) do?

Q-19. What is a variable? What are comments?

COMPUTER SCIENCE CLASS - XI -10-


Q-20. Give 2 examples each of arithmetic and comparison binary operators.

Q-21. Give a point of difference between the following with an example for each:
(i) integer and string
(ii) L-value and R-value

Q-22. Give a point of difference between logical operators and relational operators.
Give a statement each for both the categories.

Q-23. What does the modulus operator % do? What will be the result of 7.2% 2.1?

Q-24. What is the difference between ‘5’, 5 and “5”?

Q-25. Explain the two different ways to give comments in Python.

Q-26. Name any 2 operators in the arithmetic operator category. Give an example
for each.

Q-27. What is the difference between a=7 and a= =7?

Q-28. Explain the different types of errors that might occur while programming.

Q-29. Which function is used to read a string?

Q-30. Which symbol is used to tell the interpreter that the statement is continued
on the next line at the end of a line of code?

Q-31. What is the difference between L-value and R-value?

TYPE B: Python Statements

Q-32. Rewrite the following program after removing syntax errors: 2


x=input(“Enter a number”)
y=x+20
p=input(“Enter your name”)
q=p+”Kumar”
Print(“You entered”,q)

Q-33. Write equivalent Python expressions for the following:


i). S = ut +1/2at2
ii). H = √ 2 abas2

Q-34. Identify whether the following words belong to identifiers or keywords:


(i) float
(ii) hello

Q-35. Classify the following into various types of token:


(i) “1234”

COMPUTER SCIENCE CLASS - XI -11-


(ii) my_text

Q-36. Classify the category of operators to which the following operator belong to:
(i) >
(ii) %

Q-37. Construct logical expressions to represent the following conditions:


(i) Either age is more than 70 or members are more than equal to 8.
(ii) grade is ‘B’ and experience is more than 3 years.

Q-38. Classify the following words amongst Identifier, Keyword and Constant:

(i) break
(ii) “int”
(iii) Float
(iv) test

Q-39. Which of the following is a valid identifier?


(i) $343
(ii) mile
(iii) 9X
(iv) 8+9

Q-40. What will be x after the following statements?


x=1
y=2
x *= y + 1

Q-41. Which of the following functions return 4?


(i) int(3.4)
(ii) int(3.9)
(iii) round(3.4)
(iv) round(3.9)

Q-42. Which of the following code is correct/incorrect?


print("Programming is fun)
print(Python is fun)
print("Programming”+ “is” + “fun”)
print("Python is fun’)
Print("Programming is fun)
print("Python is fun")

Q-43. If a = 50 and b = 4, then determine the result of the following:


(i) a + = b         (ii) a % = b (iii)  a -=b
(iv) a /=b (v) a * =b         

Q-44. Evaluate the following expressions :


(x-y<z) and (y+z>x) or (x-z)<=(y-x+z)  if x= 4,y = 7 and z = 10

COMPUTER SCIENCE CLASS - XI -12-


(y-3) and (y-z) or ! (2y+z-x) if x = 13,y = 4 and z = 5

Q-45. Suppose A, B , C are integer variables A = 3, B = 3 , C = -5 and X,Y,Z are


floating point variables where X=8.8, Y=3.5, Z = -5.2. Determine the value of
the following expressions:
(a) A % C           (b) A*B/C   (c) (A*C)%B
(d)  X/Y (e) X/(X+Y)          

Q-46. Given the values of a, b, c, evaluate the following (Answer in True/False):


(x>=y)or(not(z==y)and(z<x))
(i) x=10, y=5, z=11
(ii) x=10, y=10, z=10
(iii) x=9, y=10, z=2

Q-47. Write the C++ statements for the following mathematical expressions:
(i) E = ½ mv2
(ii) S = (L + B)/2
(iii) V = 4/3π3
(iv) T = s(s-a)(s-b)(s-c)
(v) c = a2+b2
(vi) A=πr2
(vii) M = A2+ B2 + 2.A.B
(viii) V = 2∏rl

Q-48. Determine whether the following are valid/invalid identifiers:


(i) Test-video (ii) hp_printer
(iii) 123india.com (iv) a1p@
(v) ans$er (vi) Sum
(vii) float (viii) tips@vivekanand
(ix) _redfm (x) 1a_a1
(xi) ABC_123 (xii) 123_ABC
(xiii) yahoo.com (xiv) Void
(xv) abc_1

Q-49. Write Python statements for the following purposes:


(i) Input 3 integer values and find the sum
(ii) Display a string and an integer on a single line
(iii) Find the average of 5 numeric values and print the result
(iv) Input two integers from the user and print the bigger. Print a message
“EQUAL” if they are equal.
(v) Calculate and print the mean of three numbers
(vi) Find the cube root of the sum of the square of two integers
(vii) Calculate the discriminant for the three given numbers (to be calculated
as b2-4ac)

Q-50. Create the following variables:


(i) Mystring to contain hello
(ii) Myfloat to contain 2.5

COMPUTER SCIENCE CLASS - XI -13-


(iii) Myint to contain 10

Q-51. Write Python statements for the following mathematical expressions:


(i) E=mc2
(ii) KE=½mv2

Q-52. Evaluate the following:


(i) 5+6/7*2-3%4 (ii) 5/6+8-7*4%1**2
(iii) 10>7 and 2<5 or 4!=7 (iv) 65//8
(v) 7.0//2 (vi) 10- -3- -2
(vii) -23%5 (viii) ‘Hello’>’Goodbye’
(ix) 64**.5 (x) 8+-2-+5

Q-53. Determine the type of constants for the following:


(i) “TEST” (ii) +1234.567
(iii) +45 (iv) 37.20
(v) ‘X’ (vi) “Data”
(vii) 49 (viii) 23.55
(ix) “India” (x) ‘#’

TYPE C: Output Questions

Q-54. Write the output of the following program lines?


a. print (“MyPython” * 3)
print(3 * “MyPython”)
b. print (not(3<4 and 4<5))
print(not(3<4 or 4<5))

Q-55. What will be the result of a = 5/3 print (a)?


(i) float (ii) int ?

Q-56. Given that i = 4, j = 5, k = 8, what will be the result of following expressions?


(II) i<k   (ii) i<j   (iii) i<= k  
(iv) i = k (v) i==k  (vi) j>k
(vii) j>=I (viii) j != i   (ix) j != k
(x) j <= k

Q-57. What will be the result of the following if ans is 6 initially?


i). print(ans = = 8)

ii).print(ans+4==8+2)

ii). print(ans>10)

Q-58. What is the result of the following expression?


((a>=b)and (a+b)>a))
(i) a= 3, b= 0                         
(ii) a = 7, b= 7

COMPUTER SCIENCE CLASS - XI -14-


Q-59. Determine the output of the following program:
a=10
b=20
c=a*a+b*b
d=c+a*b
print(“Value of c=”,c)
print(“Value of d=”,d)
a=3-4+10
b=5*6
c=7.0/8.0
print(“These are the values: “,a,b,c)

Q-60. What is the result of eval("1 + 3 * 2")?

Q-61. If you enter 1 2 3 in three separate lines, when you run this program, what
will be displayed?
print("Enter three numbers: ")
number1 = eval(input())
number2 = eval(input())
number3 = eval(input())
average = (number1 + number2 + number3) / 3
print(average)

Q-62. What will be displayed by the following code?


x=1
x=2*x+1
print(x)

Q-63. What will be displayed by the following codes?


a)
x=1
x = x + 2.5
print(x)

b)
x, y = 1, 2
x, y = y, x
print(x, y)

Q-64. Which of the following expressions results in a value 1?


(i) 2%1
(ii) 15 % 4
(iii) 25 % 5
(iv) 37 % 6

Q-65. Suppose x is 1. What is x after x += 2?

COMPUTER SCIENCE CLASS - XI -15-


Q-66. Suppose x is 1. What is x after x=x//2 and x=x%2 ?

Q-67. Which of the following expressions will yield 0.5?


1/2
1 // 2
1.0// 2
1/ 3

Q-68. Evaluate the following:


45 / 4
45 // 4
25 % 1
24 % 5
2 ** 3
2 + 2 ** 3 / 2
2 ** 3.0
2 * 3 ** 2

Q-69. What will be the output of the following code:


a= ‘@’
print(a)
print(’a’)

Q-70. What is displayed when the following code is executed?


a)
x=1
y=x=x+1
print("y is", y)

b)
j=i=1
i += j + j * 5
print("What is i?", i)

c)
x=1
x *= x + 1
print(x)

d)
x=2
y=1
x *= y + 1
print(x,y)

Q-71. Determine the output of the following programs:


a=2
b=3

COMPUTER SCIENCE CLASS - XI -16-


c=a>b
d=a<b
e = c > d and a < b
print (c,d,e)

TYPE D: Error Based Questions

Q-72. Determine the syntax errors in the following:


a)
a = b;
b = a;
print ("Value of a:,a)
print (“Value of b:”+b);

b)
a=input("Enter a number")
b=a+10
print b
b=int(input(“Enter a number”))
print (b+” is the entered number”)

Q-73. Determine the syntax errors from the following Python code and correct them
by rewriting the entire code:
a=”Hello”
Print (a)
b=7
print (a+b)

Q-74. Rewrite the following program after removing syntax errors:


x=input(“Enter a number”)
y=x+20
p=input(“Enter your name”)
q=p+”Kumar”
Print(“You entered”,q)

TYPE E: Programs

Q-75. Write Python programs for the following purposes:


(i) Interchange the values of two variables with/without using third
variable
(ii) Convert centimetres to inches
(iii) Convert radians to degrees
(iv) Convert Celsius to Fahrenheit
(v) Ask for the names of 2 persons, and say Hello to both of them
(vi) Calculate simple interest for the entered values of Principal Amount,
Rate of Interest and Time Period
(vii) Evaluate area and circumference of a circle for given value of radius

COMPUTER SCIENCE CLASS - XI -17-


Q-76. Write a program which will raise any number X to a positive power n. Obtain
values of x and n from the user.

Q-77. Write a python program to input the principal amount and time. If the time is
more than 10 years, calculate the simple interest rate 8%. Otherwise
calculate it at a rate 12% per annum.

Q-78. Write a program to input a number. If the number is even, print its square
otherwise print its cube.

Q-79. Write a program to input a number. If the number is odd and positive, print
its Square root otherwise print double of the number.

Q-80. Write a program to input choice(1 or 2). If the choice is 1, print the area of a
circle otherwise print the perimeter of the circle. Accept the radius of the
circle from the user.

Q-81. Write a program to input a student type (‘A’ or ‘B’). If the student type is
‘A’initialize the college account with Rs. 200/- otherwise initialize the hostel
account with Rs. 200/-.

Q-82. Write a program to find and print the area of a triangle by asking the user to
input the base and altitude of the triangle.

Q-83. Write a program to input the name of the student, marks of 3 subjects,
calculate and print the total and percentage secured by the student, along
with his/her name.

Unit 1: Programming and Computational Thinking (PCT-1)

Chapter 2: CONDITIONAL STRUCTURES

TYPE A: Theoretical Questions

Q-1. What is an if statement? What is the purpose of if..elif...else statement?

TYPE B: Python Statements

Q-2. Write Python statement for the following

a) if variable x is positive print “+ve” otherwise print “-ve”


b) grade is ‘B’ and experience is more than 3 years.

COMPUTER SCIENCE CLASS - XI -18-


TYPE C: Output Questions

Q-3. Find the output for the following code:


a=7
b=10
c=a+b/2.5*2
d=a-b+c
print(c,d)
if c>d:
print(“Google”)
else:
print(“Microsoft”)

Q-3. Find the output for the following code if user inputs the following values for
year:
a) 2000
b) 1971
year=int (input(“enter 4 digit year”))
if year % 100 == 0:
if year % 400 == 0:
print(“leap year”)
elif year % 4 ==0 :
print(“leap year”)

Q-4. Write the output of the following code:


x= 1
if x>3 :
if x>4 :
print(‘a’)
    else:
print(‘b’)
elif x<2 :
if (x ! =0):
print(‘c’)
print(‘d’)

Q-5. Write the output of the following code:


a=4
b=7

c=a%3+b%2
if c>a:
print(a+c)
print(b+c)
else:
print(a+b)
print(a+c)

COMPUTER SCIENCE CLASS - XI -19-


if c<b:
print(b+c)
print(a+b)
else:
print(a+c)
print(b+c)

TYPE D: Error Based Questions

Q-6. Correct the syntax of the following Python code:


x=15
y=’10’
if x>y:
print(x+“x is greatest”)
elif x>z:
print(“none”)
else
print(y,“y is greatest”)

Q-7. Correct the syntax of the following Python code:


A=100
B==200
If (A=>B):
print (“yes”)
else
print (“no’)

TYPE E: Programs

Q-8. Write a program to find the largest number among the three input numbers.

Q-9. Write a program that reads two numbers and an arithmetic operator and
displays the results.

Q-10. Write a program to calculate roots of quadratic equation ax 2 + bx + c=0, to


determine the nature and value of the roots.

Q-11. Write a program to take values of length and breadth of a rectangle from the
user and check if it is square or not.

Q-12. A shop will give a discount of 10% if the cost of the quantity purchased is
more than 1000. Write a program to formulate the given situation.

Q-13. A school has following rules for grading system:


Below 25 - F
25 to 45 - E
45 to 50 - D
50 to 60 - C

COMPUTER SCIENCE CLASS - XI -20-


60 to 80 - B
Above 80 – A
Write a program to ask the user to enter marks and print the corresponding
grade.

Q-14. Write a program to input 3 numbers, find the smallest number and print it.

Q-15. Write a program to input the values of a, b & c and arrange them in
ascending order.

Q-16. Write a program to determine whether a given year is a leap year or not.

Q-17. Write a program to ask for the user’s choice to calculate the area of a triangle
according to (a) Base-Altitude formula or (b) Heron’s Formula. Have the
following printed to communicate the options available and take input from
the user accordingly:
AREA OF TRIANGLE
● Base-Altitude Formula
● Heron’s Formula

Q-18. Write a program to input the consumer’s name, consumer’s age and calls
made, and calculate the amount of telephone bill applicable as per the
following table:
Calls made Rate per unit
0-100 Free
101-500 5
501-1000 8
>1000 10
An additional monthly rental of INR 150, is charged for every consumer
irrespective of the number of calls made. Print the total amount of telephone
bill payable.

Q-19. Write a program to determine and print whether a given number is even or
odd.

Q-20. Write a program to determine and print whether a given number is a perfect
square or not.

Q-21. Write a program to determine and print whether a given is positive, negative
or zero.

Q-22. Write a program to input electricity unit charges and calculate total
electricity bill according to the given condition:
For first 50 units Rs. 0.50/unit
For next 100 units Rs. 0.75/unit
For next 100 units Rs. 1.20/unit
For unit above 250 Rs. 1.50/unit
An additional surcharge of 20% is added to the bill

COMPUTER SCIENCE CLASS - XI -21-


Q-23. Write a program to check whether a character is present in the string or not.

Q-24. Write a program to input any alphabet and check whether it is a vowel or
consonant.

Q-25. Write a program to input any character and check whether it is an alphabet,
a digit or a special character.

Q-26. Write a program to check whether a character is uppercase or lowercase


alphabet.

Q-27. Write a program to input week numbers and print week day.

Q-28. Write a program to input month number and print number of days in that
month.

Q-29. Write a program to count the total number of 2000, 500, 100, 50, 20, 10,
5 ,2, 1 notes in a given amount.

Q-30. Write a program to input angles of a triangle and check whether triangle is
valid or not.

Q-31. Write a program to input all sides of a triangle and check whether the
triangle is valid or not.

Q-32. Write a program to check whether the triangle is equilateral, isosceles or


scalene triangle.

Q-33. Write a program to find the roots and nature of a linear equation of 2
variables.

Q-34. Write a program to input marks of five subjects Physics, Chemistry, Biology,
Mathematics and Computer. Calculate percentage and grade according to the
following:
Percentage >= 90% : Grade A
Percentage >= 80% : Grade B
Percentage >= 70% : Grade C
Percentage >= 60% : Grade D
Percentage >= 40% : Grade E
Percentage < 40% : Grade F

Q-35. Write a program to input basic salary of an employee and calculate its Gross
salary according to the following:
Basic Salary <= 10000 : HRA = 20%, DA = 80%
Basic Salary <= 20000 : HRA = 25%, DA = 90%
Basic Salary >20000 : HRA = 30%, DA = 95%

COMPUTER SCIENCE CLASS - XI -22-


Unit 2: Programming and Computational Thinking (PCT-1)

Chapter 3: ITERATIVE STRUCTURES

TYPE A: Theoretical Questions

Q-1. What is a loop? How many different kinds of looping statements does python
support?

Q-2. What are the four elements of a while loop?

Q-3. Give the differences between for loop and while loop.

Q-4. What is Debugging?

Q-5. Give one difference between break and continue.

Q-6. What is the purpose of range in for loop? Give an example in python.

TYPE B: Python Statements

Q-8. A for loop that starts at 29 and ends at 11 with a decrement of 2 after each
iteration

Q-9. Convert the following code that uses while statement, into for statement:
a)
m=4
while m<=40:
print(m)
m=m+3
b)
i=1
while i<10:
print(i)
i+=2

Q-10. Convert the following code that uses for statement, into while statement:
for i in range(5,15,3):
print(i*i)

Q-11. Rewrite the following loop using while loop:


for i in range(1,16):
     if i%3==0:

COMPUTER SCIENCE CLASS - XI -23-


       print(i)

Q-12. Write python statements for the following:


i) A while loop that executes 25 times with an initial value of 35.
ii) A for loop that starts at 12 and ends at zero with a decrement of 1 after
each iteration
iii) A for loop that starts from 75 and ends at 100 with increment of 5 after
each iteration.
iv) A while loop that starts at 26 and ends at 11 with a decrement of 3 after
each iteration

TYPE C: Output Questions

Q-13. What will be the output after executing the following code?
a)
a=0
for i in range(10):
a=a+1
print(a)

b)
for i in range(4):
print(“CBSE”)

c)
x=2
for y in range(20,10,5):
y=y*2
print(x+y)
x=x+2
print(x+y)

Q-14. Determine the output of the following Python code:


i) a=5
for b in range(10,20,3):
b=a+b
print(b)
a=a+b
ii) p=6
i=2
while p>2:
p+=i+p
p=p-1
i=i+2
print(p+i)

iii) m=2
for n in range(3,8,2):

COMPUTER SCIENCE CLASS - XI -24-


m+=n
print(m)
n*=2
print(n)
iv) x=6
j=2
while x<10:
j*=2
x+=1
print(j+x)

TYPE D: Error Based Questions

Q-15. Rewrite the following program after removing syntax errors (do underline the
corrections):
x=4
while y>10:
if y>x
print x+y
break

Q-16. Correct the syntax errors in the following program:


for z in Range(10,20,2):
print z
i=i+1
If x=10
break

Q-17. Rewrite the following Python code correcting all the syntax errors that appear
in the code (do underline all the corrections):
x=20
while (x>10)
print(x)
x=x-1
else
print(“Bye”)

Q-18. Rewrite the following Python code correcting all the syntax errors that appear
in the code (do underline all the corrections):
while i in range(10,20):
Print(i)
x=x-1
print x

TYPE E: Programs

COMPUTER SCIENCE CLASS - XI -25-


Q-19. Write programs to print the following series using for loop:
(i) 1,3,5,7,9,11,13……….n terms
(ii) 2,4,6,8,10……………….n terms
(iii) 20,18,16,14,12,…………2
(iv) 0,3,6,9………………………n terms

Q-20. Write a program to print the factorial of a given number using while loop.

Q-21. Write a program to print Fibonacci series upto first 20 elements.

Q-22. Write a program to print the following pattern:


1
12
123
1234

Q-23. Write a Python program to determine whether a given number is prime or


not.

Q-24. Program to find the sum of the series s=1+x+x2+x3+….xn

Q-25. Write a Python program to evaluate the following sum of series:


S=1+X/2+X2/3+X3/4+X4/5+…Xn/n+1

Q-26. Write a program to evaluate the following sum of series:


S=2/X2+3/X3+4/X4+5/X5+…n/Xn
Q-27. Write a program to evaluate the following sum of series:
S=1/X+3/X2+5/X3+7/X4

Q-28. Write a Python program to determine whether a given number is a perfect


square or not.

Q-29. Write a Python program to print whether a given number is an Armstrong


number or not.

Q-30. Write a Python program to print the reverse of a given number.

Q-31. Write a Python program to print the sum of the digits of a given number.

Q-32. Write a Python program to display the first n natural numbers.

Q-33. Write a Python program to display the first 10 even numbers.

Q-34. Write a Python program to display the sum of odd numbers from 1 to n.

Q-35. Write a Python program to display the maximum of 20 numbers.

COMPUTER SCIENCE CLASS - XI -26-


Q-36. Write a Python program to find the sum of the first n numbers that are
divisible by 5, where n is taken as input from the user.

Unit 2: Programming and Computational Thinking (PCT-1)

Flowcharts , Algorithms

TYPE A: Theoretical Questions

Q-1. What is flowchart? Explain the various symbols used to design a flowchart.
Q-2. What is an algorithm?

TYPE B: Manipulative Questions

Flowchart

Q -1. Draw the flowchart for finding value and nature of the roots of a quadratic
equation.
Q-2. Draw the flowchart for finding the biggest of 3 numbers.
Q-3. Draw the flowchart for calculating the sum of any given 2 numbers.
Q-4. Draw the flowchart for evaluating and printing the factorial of a number.
Q-5. Draw the flowchart for printing the Fibonacci series till n.
Q-6. Draw the flowchart for evaluating and printing the area of a circle.

Algorithm

Q-7. Write the algorithm to print all natural numbers from 1 to n. 
Q-8. Write the algorithm to check whether a number is Prime number or not.
Q-9. Write the algorithm to determine whether a set of 3 numbers can be
considered as Pythagorean triplets or not.
Q-10. Write the algorithm for finding and print the area of a triangle using Heron's
formula
Q-11. Write the algorithm to check whether a number is negative, positive or zero.
Q-12. Write the algorithm to calculate the sum of digits of a number.

STRINGS IN PYTHON

1. What will be the output of following code

str="hello"

str[:2]

2 What will be the output of following codestr='Hello'

res=''

for i in range(len(str)):

COMPUTER SCIENCE CLASS - XI -27-


res=res+str[i]

print(res)

3 What will be the output of following codes='Hi!'

s1='Hello'

s2=s[:2]+s1[len(s1)-2:]

print(s2)

4 What will be the output of following code-

'ba'+'na'*2

5 What will be the output of following code

s='Welcome to python4csip.com'

print(s.find('come'))

s.count('o')

6 What will be the output of following program:

s='Hello'

for i in s:

print(i,end='#')

7 What will be the output of following program:

for i in 'hardik':

print(i.upper())

8 What will be the output of following program:

s='Hello'

for i in s:

print('Welcome')

9 What will be the output of following program:

str='virat'

for i in str:

print(str.upper())

10 What will be the output of following program:

COMPUTER SCIENCE CLASS - XI -28-


a='hello'

b='virat'

for i in range(len(a)):

print(a[i],b[i])

11. What will be the output of following program:

a='hello'

b='virat'

for i in range(len(a)):

print(a[i].upper(),b[i])

12 What will be the output of following program:

print("xyyzxyzxzxyy".count('xyy', 2, 11))

13 What will be the output of following program:

print(“hello”+1+2+3)

14 What will be the output of following program:

str1 = "PYTHON4CSIP.COM"

print(str1[1:4], str1[:5], str1[4:], str1[0:-1], str1[:-1])

15 What will be the output of following program:

str = "my name is kunfu pandya";

print (str.capitalize())

16 What will be the output of following program:

str1 = 'Hello'

str2 ='World!'

print('str1 + str2 = ', str1 + str2)

print('str1 * 3 =', str1 * 3)

17 What will be the output of following program:

count = 0

for letter in 'Hello World':

if(letter == 'l'):

COMPUTER SCIENCE CLASS - XI -29-


count += 1

print(count,'letters found')

COMPUTER SCIENCE CLASS - XI -30-


Lists, Tuples and Dictionaries

Python Lists

TYPE A: Theoretical Questions

Q-1. How To Select An Element From A List?

Q-2. What Does The Index Out Of Range Error Mean?

Q-3. How To Convert A List To A String?

TYPE B: Python Statements

Q-4. Given a list of numbers, find and print all its elements with even indices (i.e.
A[0], A[2], A[4], ...).

Q-5. Given a list of numbers, print all its even elements. Use a for-loop that
iterates over the list itself and not over its indices. That is, don't use range()

Q-6. Given a list of numbers, find and print all its elements that are greater than
their left neighbour.

Q-7. Given a list of non-zero integers, find and print the first adjacent pair of
elements that have the same sign. If there is no such pair, print 0.

Q-8. Given a list of numbers with all elements sorted in ascending order,
determine and print the number of distinct elements in it.

Q-9. Given a list of integers, find the first maximum element in it. Print its value
and its index (counting with 0).

Q-10. Given a list of numbers, find and print the elements that appear in it only
once. Such elements should be printed in the order in which they occur in
the original list.

Q-12.   Given an integer n, create a two-dimensional array of size n×n according to


the following rules and print it: 

On the main diagonal put 0. On the diagonals adjacent to the main put 1. 

On the next adjacent diagonals put 2, and so forth.

Example input:             5

Example output: 0 1 2 3 4

10123

21012

COMPUTER SCIENCE CLASS - XI -31-


32101

43210

LIST IN PYTHON MCQ

Q1. Which of the following statement will create list?

(A) L1=list( )

(B) L1=[1,2,3,4]

(C) Both of the above

(D) None of the above

2 Write the output of the following code :

list(“welcome”)

(A) [‘w’, ‘e’, ‘l’, ‘c’, ‘o’, ‘m’, ‘e’]

(B) (‘w’, ‘e’, ‘l’, ‘c’, ‘o’, ‘m’, ‘e’)

(C) [‘welcome’]

(D) None of the above

3 Write the output of the following code :

>>> L=[‘w’,’e’,’l’,’c’,’o’,’m’,’e’]

>>> print(len(L))

(A) 7

(B) 8

(C) 9

(D) None

4 Write the output of the following code :

>>> L=[“Amit”,”Anita”,”Zee”,”Longest Word”]

>>> print(max(L))

(A) Zee

(B) Longest Word

(C) Error

(D) None of the above

COMPUTER SCIENCE CLASS - XI -32-


5 Write the output of the following code :

>>>L=[1,2,3,4,5,[6,7,8]]

>>>print(L[5])

a. [6, 7, 8]

b. 6, 7, 8

c. Error

d. 6

6 Write the output of the following code :

L=list(“www.csiplearninghub.com”)

print(L[20 : -1])

a. [‘c’ , ‘o’]

b. [‘c’ , ‘o’ , ‘m’]

c. (com)

d. Error

7 Write the output of the following code :

>>>L=list(“www.csiplearninghub.com”)

>>>print(L[20 : 0])

a. Error

b. No Value

c. None

d. [ ]

8 Write the output of the following code :

L=[“Amit”,”Sumit”,”Naina”]

print(L*2)

a. [‘Amit’, ‘Sumit’, ‘Naina’, ‘Amit’, ‘Sumit’, ‘Naina’]

b. [“Amit” , “Sumit” , “Naina”]

c. Error

d. None of the above

COMPUTER SCIENCE CLASS - XI -33-


9 Write the output of the following code :

L=[“Amit”,”Sumit”,”Naina”]

print(L**2)

a. Error

b. [“Amit”,”Sumit”,”Naina”][“Amit”,”Sumit”,”Naina”]

c. [“Amit”,”Sumit”,”Naina”]

d. [“Amit”,”Sumit”,”Naina”,”Amit”,”Sumit”,”Naina”]

10 Write the output of the following code :

L=[0.5 * x for x in range(4)]

print(L)

a. [0.0, 0.5, 1.0, 1.5]

b. (0,.5, 1, 1.5)

c. [0.0, 0.5, 1.0, 1.5, 2.0]

d. Error

11 Write the output of the following code :

L=[1,2,3,4,5]

for i in L:

print(i,end=” “)

i=i+1

a. 1, 2, 3, 4, 5

b. 1, 3, 5

c. Error

d. None of the above

12 Which command is used to add an element in List named L1

a. L1.add(4)

b. L1.append(4)

c. L1.new(4)

d. None of the above

COMPUTER SCIENCE CLASS - XI -34-


13 Index value in list and string start from 0(T/F)

a. True

b. False

14 del statement can delete the following from the List?

a. Single Element

b. Multiple Elements

c. All elements along with List object

d. All of the above

15 What type of error is returned by the following statement?

T = [1,2,3,4]

print(T.index(9))

a. IndexError

b. TypeError

c. ValueError

d. None of the above

16 Which mathematical operator is used for repetition?

a. *

b. **

c. +

d. //

17 Which of the following is not list operation?

a. Indexing

b. Slicing

c. Dividing

d. Concatenation

18 Which of the following is true about List data type in Python?

a. List is a Sequence data type

b. List is mutable

COMPUTER SCIENCE CLASS - XI -35-


c. List can have elements of different data type

d. All of the above

19 List can have elements of _____________ data types.

a. Same

b. Different

c. Both of the above

d. None of the above

20 Which operator helps to check whether an element is present in list or not?

a. +

b. in

c. **

d. None of the above

21 sort () function Sorts the elements of the given list in-place(T/F)

a. True

b. False

22 Which of the following function creates the new list?

a. sort( )

b. sorted( )

c. reverse( )

d. All of the above

23 Which of the following will give output as [21,2,9,7] ? if list L = [1,21,4,2,5,9,6,7]

a. print(L[1 : 8 : 2])

b. print(L[1 : : 2])

c. Both of the above

d. None of the above

24 Write the output of the following :

L = [11, 21, 31, 41]

L.extend([51,62,73,84])

COMPUTER SCIENCE CLASS - XI -36-


print(len(L))

a. 8

b. 4

c. 5

d. Error

25 Both the print statement will produce the same result.(T/F)

L = ["Amit", "Ananya", "Parth"]

print(L[-1])

print(L[-1][-1])

a. True

b. False

Python Tuples

TUPLE IN PYTHON MCQ

1 Tuples are __________________

a. Mutable

b. Immutable

c. Mutable to some extent

d. None of the above

2 Tuples can contain elements of any data type.(T/F)

a. True

b. False

3 In tuples values are enclosed in __________________

a. Square brackets

b. Curly brackets

c. Parenthesis

d. None of the above

COMPUTER SCIENCE CLASS - XI -37-


4 Write the output of the following.

A = tuple(“Python”)

print(A)

a. (python)

b. (“Python”)

c. (‘P’ , ‘y’ , ‘t’ , ‘h’ , ‘o’ , ‘n’)

d. None of the above

5 len( ) function returns the number of elements in tuple.(T/F)

a. True

b. False

6 Write the output of the following:

A = list(tuple(“Python”))

print(A)

a. (‘P’, ‘y’, ‘t’, ‘h’, ‘o’, ‘n’)

b. [‘P’, ‘y’, ‘t’, ‘h’, ‘o’, ‘n’]

c. none of the above

d. Error

7. Which of the following is not a function of tuple?

a. update( )

b. min( )

c. max( )

d. count( )

8 Which of the following is/are features of tuple?

a. Tuple is immutable

b. Tuple is a sequence data type.

c. In tuple, elements are enclosed in Parenthesis.

d. All of the above

9 Which of the following is not a tuple?

COMPUTER SCIENCE CLASS - XI -38-


a. P = 1,2,3,4,5

b. Q = (‘a’, ‘b’, ‘c’)

c. R = (1, 2, 3, 4)

d. None of the above

10 Which of the following statement will create an empty tuple?

a. P = ( )

b. Q = tuple( )

c. Both of the above

d. None of the above

11 Which of the following is a tuple with single element?

a. t = (1,)

b. t = 1,

c. Both of the above

d. None of the above

12 Write the output of the following:

>>>t = (1)

>>>type(t)

a. <class ‘int’>

b. <class ‘float’>

c. <class ‘tuple’>

d. <class ‘list’>

13 What is the length of the given tuple? >>> t1=(1,2,(3,4,5))

a. 1

b. 2

c. 3

d. 4

14 Which of the following statement will return an error. T1 is a tuple.

a. T1 + (23)

COMPUTER SCIENCE CLASS - XI -39-


b. T1 + [3]

c. Both of the above

d. None of the above

15 Which mathematical operator is used to replicate a tuple?

a. Addition

b. Multiplication

c. Exponent

d. Modulus

16 Which of the following function return the frequency of particular element in


tuple?

a. index( )

b. max( )

c. count( )

d. None of the above

17 Write the output of the following :

>>> t1=(1,2,3,4,5,6,7)

>>> t1[t1[1]] + t1[t1[-4]]

a. 8

b. 9

c. 6

d. 7

18 Which function takes tuple as argument?

a. max( )

b. min( )

c. sum( )

d. All of the above

19 What type of error is returned by following code :

a=(“Amit”, “Sumit”,”Ashish”,”Sumanta”)

print(a.index(“Suman”))

COMPUTER SCIENCE CLASS - XI -40-


a. SyntaxError

b. ValueError

c. TypeError

d. NameError

20 Write the output of the following.

a=(23,34,65,20,5)

print(a[0]+a.index(5))

a. 28

b. 29

c. 27

d. 26

TYPE A: Theoretical Questions

Q-1. What is tuple in Python ?

Q-2.   Differentiate between lists and tuples. 

Q-3. How will you convert a string to a tuple in python?

Q-4. Can we create a tuple of tuples?

Q-5. Write any 2 equalities between list and tuple?

Q-6. How can we compare items of two tuples? 

Q-7. Write short notes on any 4 python tuple functions

Q-8. Write a Python program to reverse a tuple element.

Q-9. How will you create a tuple from a dictionary ?

Q-10. What are the advantages of tuple over list? 

TYPE B: Python Statement Questions

Q-11. Create a tuple containing just a single element which in turn contains the
four elements 'a', 'b',’c’ and 'd'. Verify that the length is actually 1 by using
the len() function. 

COMPUTER SCIENCE CLASS - XI -41-


Q-12. Create the tuple ('x', 'y', 'z'), then create a list from that tuple. 

TYPE C: Output Questions

Q-13. What is the output of print tuple * 2 if tuple = (123, ‘FREYA’)?

Q-14. What Will Be The Output Of The Following Code Snippet? 

  tuple_a = 1, 2

  tuple_b = ('3', '4')

  print (tuple_a + tuple_b)

Q-15. What Will Be The Output Of The Following Code Snippet?

 tuple_a = 1, 2 

 tuple_b = (3, 4)

 r=[sum(x) for x in [tuple_a + tuple_b]] 

 print(r) 

Q-16. What Will Be The Output Of The Following Code Snippet? 

 tuple = ('Python') * 4

 print(type(tuple)) 

Q-17. What will be the output?

 t=(11,121,14,13)  

print(t[1:3]) 

Q-18. What will be the output?

t = (11, 12, 14, 13, 18, 19) 

r=[t[i] for i in range(0, len(t), 2)]

print(r) 

Q-19. What will be the output?

 t1 = (1, 2, 3, 3)

 t2 = (1, 2, 3, 4)

 print(t1 < t2) 

Q-20. What is the output of the following piece of code?

COMPUTER SCIENCE CLASS - XI -42-


tup1=(23,1,45,46,67,45,9,55,45)

tup2=(100,200)

(i) print(tup1.index(45))

(ii) print(len(tup2))

(iii) print(sum(tup2))

(iv) print(sorted(tup1)

print(tup1)

TYPE D: Programs

Q-21. Write a Python program to find the index of an item of a tuple. 

Q-22. Write a Python program to create a tuple with numbers from 1 to 10 and
print all the items one at a time in a separate line. 

Q23. Write a python program to print the second largest element in tuple.

Python Dictionaries

DICTIONARY IN PYTHON (MCQ)

1 In order to store values in terms of key and value we use what core data type

(A) list

(B) tuple

(C) class

(D) dictionary

2 What is the output of the following code?

a={1:"A",2:"B",3:"C"}

print(a.setdefault(3))

(A) {1: ‘A’, 2: ‘B’, 3: ‘C’} c) d)

(B) C

(C) {1: 3, 2: 3, 3: 3}

(D) No method called setdefault() exists for dictionary

3 Which of the following statements create a dictionary?

COMPUTER SCIENCE CLASS - XI -43-


(A) d = {}

(B) d = {“john”:40, “peter”:45}

(C) d = {40:”john”, 45:”peter”}

(D) All of the mentioned

4 Read the code shown below carefully and pick out the keys?

d = {"john":40, "peter":45}

(A) “john”, 40, 45, and “peter”

(B) “john” and “peter”

(C) 40 and 45

(D) d = (40:”john”, 45:”peter”)

5 d = {"john":40, "peter":45}

"john" in d

(A) True

(B) False

(C) None

(D) Error

6 What will be the output?

d1 = {"john":40, "peter":45}

d2 = {"john":466, "peter":45}

d1 == d2

(A) True

(B) False

(C) None

(D) Error

7 What will be the output?

d1 = {"john":40, "peter":45}

d2 = {"john":466, "peter":45}

d1 > d2

COMPUTER SCIENCE CLASS - XI -44-


(A) True

(B) False

(C) Error

(D) None

8 What is the output? d = {"john":40, "peter":45}

d["john"]

(A) 40

(B) 45

(C) “john”

(D) “peter”

9 Suppose d = {“john”:40, “peter”:45}, to delete the entry for “john” what command
do we use:

(A) d.delete(“john”:40)

(B) d.delete(“john”)

(C) del d[“john”]

(D) del d(“john”:40)

10 Suppose d = {“john”:40, “peter”:45}. To obtain the number of entries in dictionary


which command do we use?

(A) d.size()

(B) len

(C) size

(D) d.len()

11 What will be the output?

d = {"john":40, "peter":45}

print(list(d.keys()))

(A) [“john”, “peter”]

(B) [“john”:40, “peter”:45]

(C) (“john”, “peter”)

(D) (“john”:40, “peter”:45)

COMPUTER SCIENCE CLASS - XI -45-


12 Which of the following is correct with respect to above Python code?

d = {"a”:3 ,”b”: 7}

print(list(d.keys()))

(A) a dictionary d is created.

(B) a and b are the keys of dictionary d.

(C) 3 and 7 are the values of dictionary d

(D) All of the above.

13 Which one of the following is correct?

A. In python, a dictionary can have two same keys with different values.

B. In python, a dictionary can have two same values with different keys

C. In python, a dictionary can have two same keys or same values but cannot have
two same key-value pair

D. In python, a dictionary can neither have two same keys nor two same values.

14 What will be the output of above Python code?

d1={"abc":5,"def":6,"ghi":7}

print(d1[0])

A. abc

B. 5

C. {"abc":5}

D. Error

15 What will the below Python code do?

dict={"Phy":94,"Che":70,"Bio":82,"Eng":95}

dict.update({"Che":72,"Bio":80})

A. It will create new dictionary as dict={"Che":72,"Bio":80} and old dict will be


deleted.

B. It will throw an error as dictionary cannot be updated.

C. It will simply update the dictionary as dict={"Phy":94,"Che":72,"Bio":80,"Eng":95}

D. It will not throw any error but it will not do any changes in dict

16 What will be the output of above Python code?

COMPUTER SCIENCE CLASS - XI -46-


d1={"abc":5,"def":6,"ghi":7}

print(d1[0])

A. abc

B. 5

C. {"abc":5}

D. Error

17 Which of the following will delete key_value pair for key="tiger" in dictionary?

dic={"lion":"wild","tiger":"wild","cat":"domestic","dog":"domestic"}

A. del dic["tiger"]

B. dic["tiger"].delete()

C. delete(dic.["tiger"])

D. del(dic.["tiger"])

18 Which of the following will give error?

Suppose dict1={"a":1,"b":2,"c":3}

A. print(len(dict1))

B. print(dict1.get("b"))

C. dict1["a"]=5

D. None of these.

19 Which of the following Python codes will give same output if

(i) dict.pop("book")

(ii) del dict["book"]

(iii) dict.update({"diary":1,"novel":5})

dict={"diary":1,"book":3,"novel":5}

A. i, ii, iii

B. i, ii

C. i, iii

D. ii, iii

20 Keys of the dictionary must be :

COMPUTER SCIENCE CLASS - XI -47-


A. Similar

B. Unique

C. Can be similar or unique

D. All of these

21 Which of these about a dictionary is false?

A. The values of a dictionary can be accessed using keys

B. The keys of a dictionary can be accessed using values

C. Dictionaries aren’t ordered

D. Dictionaries are mutable

22 Which of the following is not a declaration of the dictionary?

A. {1: ‘A’, 2: ‘B’}

B. dict([[1,”A”],[2,”B”]])

C. {1,”A”,2”B”}

D. { }

23 What will be the output of the following Python code snippet?

a={1:"A",2:"B",3:"C"}

print(a.get(1,4))

A. 1

B. A

C. 4

D. Invalid syntax for get method

24 What will be the output of the following Python code snippet?

a={1:"A",2:"B",3:"C"}

print(a.get(5,4))

A. 1

B. A

C. 4

D. Invalid syntax for get method

COMPUTER SCIENCE CLASS - XI -48-


25 What will be the output of the following Python code snippet?

a={1:"A",2:"B",3:"C"}

a.setdefault(4,"D")

print(a)

A. {1: ‘A’, 2: ‘B’, 3: ‘C’, 4: ‘D’}

B. None

C. Error

D. [1,3,6,10]

26 What will be the output of the following Python code?

a={1:"A",2:"B",3:"C"}

b=a.copy()

b[2]="D"

print(a)

A. Error, copy() method doesn’t exist for dictionaries

B. {1: ‘A’, 2: ‘B’, 3: ‘C’}

C. {1: ‘A’, 2: ‘D’, 3: ‘C’}

D. “None” is printed

27. What will be the output of the following Python code?

a={1:"A",2:"B",3:"C"}

a.clear()

print(a)

A. None

B. { None:None, None:None, None:None}

C. {1:None, 2:None, 3:None}

D. { }

28. What will be the output of the following Python code?

a={1:5,2:3,3:4}

a.pop(3)

COMPUTER SCIENCE CLASS - XI -49-


print(a)

A. {1: 5}

B. {1: 5, 2: 3}

C. Error, syntax error for pop() method

D. {1: 5, 3: 4}

29. What will be the output of the following Python code?

a={1:"A",2:"B",3:"C"}

for i in a:

print(i,end=" ")

A. 1 2 3

B. ‘A’ ‘B’ ‘C’

C. 1 ‘A’ 2 ‘B’ 3 ‘C’

D. Error, it should be: for i in a.items():

30. What will be the output of the following Python code?

>>> a={1:"A",2:"B",3:"C"}

>>> a.items()

A. Syntax error

B. dict_items([(‘A’), (‘B’), (‘C’)])

C. dict_items([(1,2,3)])

D. dict_items([(1, ‘A’), (2, ‘B’), (3, ‘C’)])

Assertion and Reasoning :

1. In the question given below, there are two statements marked as Assertion (A) and
Reason (R). Mark your answer as per the options provided.

Assertion(A): Dictionaries are enclosed by curly braces { }

Reason(R): The key-value pairs are separated by commas ( , )

A. Both A and R are true and R is the correct explanation of A.

B. Both A and R are true but R is not the correct explanation of A.

C. A is true but R is false.

D. A is false but R is true.

COMPUTER SCIENCE CLASS - XI -50-


2. Reason(R): The pop() method deletes the key-value pair and returns the value of
deleted element.

A. Both A and R are true and R is the correct explanation of A.

B. Both A and R are true but R is not the correct explanation of A.

C. A is true but R is false.

D. A is false but R is true.

3. Assertion(A): clear() method removes all elements from the dictionary

Reason(R): len() function cannot be used to find the length of a dictionary.

A. Both A and R are true and R is the correct explanation of A.

B. Both A and R are true but R is not the correct explanation of A.

C. A is true but R is false.

D. A is false but R is true.

4. Assertion(A): keys() of the dictionaries must be unique.

Reason(R): The keys of a dictionary can be accessed using values.

A. Both A and R are true and R is the correct explanation of A.

B. Both A and R are true but R is not the correct explanation of A.

C. A is true but R is false.

D. A is false but R is true.

5. Assertion(A): A dictionary consists of a collection of key-value pairs.

Reason(R): Each key-value pair maps the key to its associated value.

A. Both A and R are true and R is the correct explanation of A.

B. Both A and R are true but R is not the correct explanation of A.

C. A is true but R is false.

D. A is false but R is true.

6. Assertion(A): The random module is a built-in module to generate the pseudo-


random variables.

Reason(R): The randrange() function is used to generate a random number between


the specified range in its parameter.

A. Both A and R are true and R is the correct explanation of A.

B. Both A and R are true but R is not the correct explanation of A.

COMPUTER SCIENCE CLASS - XI -51-


C. A is true but R is false.

D. A is false but R is true.

7. Assertion(A): The randint() method returns an integer number selected element


from the specified range.

Reason(R): The syntax for randint() is : random.randint(start: stop)

A. Both A and R are true and R is the correct explanation of A.

B. Both A and R are true but R is not the correct explanation of A.

C. A is true but R is false.

D. A is false but R is true.

TYPE A: Theoretical Questions

Q-1. What is a Dictionary?

Q-2. Write the method by which we can declare a dictionary.

Q-3. Can we modify a dictionary? Explain with an example.

Q-4. What are dictionary keys?

Q-5. How many ways are there to create dictionaries? Name them?

Q-6. Why can’t Lists be used as Keys?

Q7. Why a dictionary is termed as unordered collection of object?

TYPE C: Output Questions

Q-8. What will be the output of the following Python code?

Dic = {1:10, 2:20, 3:30, 4:40, 5:50}

print(Dic.items())

print(Dic.keys())

print(Dic.values()

Q-9. What Will Be The Output Of The Following Code Snippet?

a = {(1,2):1,(2,3):2}

print(a[1,2])

COMPUTER SCIENCE CLASS - XI -52-


Q-10. What will be the output of the following code fragment?

aDict={“a”:1,”b”:5,”c”:10,”d”:20}

temp=0

for v in aDict.values():

temp=temp+v

print(temp)

Q-11. What Will Be the Output Of The Following Code Snippet?

fruit = { }

L=[“Apple”,”Banana”,”apple”]

for index in L:

if index in fruit:

fruit[index] += 1

else:

fruit[index] = 1

print (len(fruit))

print(fruit)

Q-12. What Will Be The Output Of The Following Code Snippet?

dict = {'c': 97, 'a': 96, 'b': 98}

for I in sorted(dict):

print (dict[I])

Q-13. What Will Be The Output Of The Following Code Snippet?

rec = {"Name" : "Python", "Age":"20", "Addr" : "NJ", "Country" : "USA"}

id1 = id(rec)

del rec

rec = {"Name" : "Python", "Age":"20", "Addr" : "NJ", "Country" : "USA"}

id2 = id(rec)

print(id1 == id2)

COMPUTER SCIENCE CLASS - XI -53-


TYPE C: Programs

Q-14. Write a Python script to generate and print a dictionary that contains a
number (between 1 and n) in the form {x: x*x} .

Q-15. Write a Python program to remove duplicate values from Dictionary.

Unit 3: Society, Laws and Ethics

1. What is cyber safety?

2. What is the full form of ICT?

3. What are some tips for safe browsing?

4. What is identity theft?

5. Give a few examples of identity theft.

6. What is cyber trolling?

7. What is cyber bullying?

8. What is cyber stalking?

9. What is cyber harassment?

10. What do you understand by Eavesdropping? Give an example.

11. What is malware?

12. What is a computer virus?

13. What is a Trojan Horse?

14. What is a computer worm?

15. What is spam?

16. What is Phishing?

17. What is Adware?

18. What is the full form of: HTTP, HTTPS, SSL, TSL?

19. What is IP?

20. What is IPR?

21. What is Plagiarism?

22. What is a software license?

COMPUTER SCIENCE CLASS - XI -54-


23. What is GPL?

24. What is open source software?

25. What is open data?

26. What is a Privacy Law?

27. What is ITA,2000? What is the purpose of ITA, 2000?

28. What is a cybercrime? Give a few examples.

29. What are the few examples of Cybercrime?

30. What are the names of a few websites where you can lodge your complaint
related to cybercrime?

31. What is computer fraud?

32. What is cyber forensics?

33. What is e-waste?

34. What is e-waste management?

35. What are the few ways to dispose of E-waste?

36. What is biometrics? Give a few examples.

37. What is an UID?

38. What are the disability issues faced in teaching / using computers?

39. What are the possible solutions to overcome disability issues faced in teaching
/ using computers?

40. Write two net etiquettes, communication etiquettes and social media étiquettes

41. What are Digital Footprints?

COMPUTER SCIENCE CLASS - XI -55-


COMPUTER SCIENCE CLASS - XI -56-
COMPUTER SCIENCE CLASS - XI -57-
COMPUTER SCIENCE CLASS - XI -58-
COMPUTER SCIENCE CLASS - XI -59-

You might also like