12 CS Worskheet

Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

KAHNA MAKHAN PUBLIC SCHOOL, VRINDAVAN

Class- XII Subject- Computer science


Worksheet
 There are 15 MCQ questions in Section A.
 There are 50 MCQ questions in Section B.
 Section C One question is to design synopsis of your project.
Section-A
1. Which of the following is the use of function in python?
a) Functions are reusable pieces of programs
b) Functions don’t provide better modularity for your application
c) you can’t also create your own functions
d) All of the mentioned
2. Which keyword is use for function?
a) Fun b) Define c) Def d) Function
3. What is the output of the below program?
def sayHello():
print('Hello World!')
sayHello()
sayHello()
a) Hello World!
Hello World!
b) ‘Hello World!’
‘Hello World!’
c) Hello
Hello
d) None of the mentioned
4. What is the output of the below program?
def printMax(a, b):
if a > b:
print(a, 'is maximum')
elif a == b:
print(a, 'is equal to', b)
else:
Page No 21
print(b, 'is maximum')
printMax(3, 4)
a) 3 b) 4 c) 4 is maximum d) None of the mentioned
5. What is the output of the below program ?
x = 50
def func(x):
print('x is', x)
x=2
print('Changed local x to', x)
func(x)
print('x is now', x)
a) x is now 50 b) x is now 2 c) x is now 100 d) None of the mentioned
6. What is the output of the below program?
x = 50
def func():
global x
print('x is', x)
x=2
print('Changed global x to', x)
func()
print('Value of x is', x)
a) x is 50
Changed global x to 2
Value of x is 50
b) x is 50
Changed global x to 2
Value of x is 2
c) x is 50
Changed global x to 50
Value of x is 50
d) None of the mentioned
7. What is the output of below program?
def say(message, times = 1):
print(message * times)
say('Hello')
say('World', 5)
a) Hello
WorldWorldWorldWorldWorld
b) Hello
World 5
c) Hello
World,World,World,World,World
d) Hello
HelloHelloHelloHelloHello
8. What is the output of below program?
def maximum(x, y):
if x > y:
return x
elif x == y:
return 'The numbers are equal'
else:
return y
print(maximum(2, 3))
a) 2 b) 3 c) The numbers are equal d) None of the mentioned
9. Which statement will read 5 characters from a file (file object ‘f’)?
a. f.read () b. f.read (5) c. f.reads (5) d. None of the above
10. The readlines() method returns
a) str b) a list of lines
c) a list of single characters d) a list of integers
11. What is the output of below program?
def cube(x):
return x * x * x
x = cube(3)
print x
a) 9
b) 3
c) 27
Page No 25
d) 30
12. What is the output of the below program?
def C2F(c):
return c * 9/5 + 32
print C2F(100)
print C2F(0)
a) 212
32
b) 314
24
c) 567
98
d) None of the mentioned
13. What is the output of the below program?
def power(x, y=2):
r=1
for i in range(y):
r=r*x
return r
print power(3)
print power(3, 3)
a) 212
32
b) 9
27
c) 567
98
d) None of the mentioned
14. To open a file c:\scores.txt for reading, we use
a) infile = open(“c:\scores.txt”, “r”) b) infile = open(“c:\\scores.txt”, “r”)
c) infile = open(file = “c:\scores.txt”, “r”) d) infile = open(file = “c:\\scores.txt”, “r”)
15. To read two characters from a file object infile, we use
a) infile.read(2) b) infile.read() c) infile.readline() d) infile.readlines()

SECTION-B
Q1. What is sorting? Name some sorting techniques.
Q2. Why do number-of-comparisons reduce in every successive iteration in bubble sort?
Q3. What is the basic principle of sorting in insertion sort ?
Q4. Number of operations wise, compare bubble sort and insertion sort techniques
Q5. What is the main difference between Bubble sort and Insertion sort techniques?
Q6. Write a program in python to sort data using bubble sort.
Q7. Write a program in python to sort data using insertion sort.
Q8. What are the steps to sort a list using bubble sort.
Assume list a=[12,3,15,6,22,2]
Q9. What are the steps to sort a list using bubble sort.
Assume list a=[11,13,23,15,6,22,2]
Q10. If a is (1, 2, 3)(a) what is the difference (if any) between a * 3 and (a, a, a)? (b) is a * 3 equivalent to
a + a + a ? (c) what is the meaning of a[1:1] ?(d) what is the difference between a[1:2] and a[1:1] ?
Q11. Does the slice operator always produce a new tuple ?
Q12. The syntax for a tuple with a single item is simply the element enclosed in a pair of matching
parentheses as shown below : t = ("a") Is the above statement true? Why? Why not ?
Q13. Are the following two assignments same ? Why / why not ? (b) T3 = (3, 4, 5) T4 = ((3, 4, 5)) (a) T1 =3,
4, 5 T2 = (3,4 ,5)
Q14. What would following statements print? Given that we have tuple = ('t', 'p', 'I') (a) print("tuple") (b)
print(tuple(“tuple")) (c) print (tuple)
Q15. How is an empty tuple created?.
Q16. How is a tuple containing just one element created?
Q17. What is a function? How is it useful?
Q18. A program having multiple function is considered better designed than a program without any
function. Why?
Q19. What is an argument? Give an example.
Q20. What is Python module? What is its significance?
Q21. What is Python library? Explain with example.
Q22. Write a program to calculate the following using modules:
(a) Energy = m * g * h (b) distance = ut + + 1/2at2 (c) Speed = distance / time
Q23. Write a module to input total number of days and find the total number of months and remaining
days after months, and display it in another program.
Q24. Write a program to calculate the volume and area of a sphere inside separate modules and import
them in one complete package.
Volume = 4/3πr3
Surface Area = 4πr2
Q25. How do you reuse the functions defined in a module in your program?
Q26. What is a module? What is the file extension of a Python module?
Q27. How do you reuse the functions defined in a module in your program?
Q28. In how many ways can you import objects from a module?
Q29. How are following import statements different?
(a) import math
(b) from math import *
Q30. How does Python resolve the scope of a name or identifier?
Q31. How are keywords different from identifiers?
Q32. Differentiate between mutable and immutable objects in Python language with example.
Q33. What are literals in Python? How many types of literals are allowed in Python?
Q34. How many ways are there in Python to represent an integer literal?
Q35. What are data types? What are Python's built-in core data types?
Q36. What do you understand by the term Iteration?
Q37. What is indexing in context to Python strings? Why is it also called two-way indexing?
Q38. What is a string slice? How is it useful?
Q39. Write a program that reads a string and checks whether it is a palindrome string or not.
Q40. How are lists different from strings when both are sequences?
Q41. How many types of strings are supported in Python?
Q42. Write a program to accept values from a user in a tuple. Add a tuple to it and display its elements
one by one. Also display its maximum and minimum value.
Q43. What is a module list? Give at least two reasons why we need modules.
Q44. How do you create your own package in Python?
Q45. What is the difference between import statement and from import statement?
Q46. Define 'module' and 'package'.
Q47. Write a method in Python to find and display the prime numbers between 2 to N. Pass argument to
the method.
Q48. Write a program with a user-defined function with string as a parameter which replaces all vowels
in the string with "*".
Q49. What is the utility of built-in function help()?
Q50. Name the Python Library modules which need to be imported to invoke the following functions:
(i) sin() (ii) randint ()

Section C
Q1. Design the synopsis documentation of project from the following topics.
 School Management System
 Library Management System
 Airline Booking System
 Payroll Management System
 Hotel Management System
 Hospital Management System

You might also like