Computer Science Grade-11 Question Bank
Computer Science Grade-11 Question Bank
COMPUTER SCIENCE
QUESTION BANK
3. To accept numbers till the user enters 0 and then find their average.
CH – 7 PYTHON FUNDAMENTALS
1. Write a program to read today's date (only del part) from user. Then display
how many days are left in the current month.
2. Write a program to input a single digit(n) and print a 3 digit number created as
<n(n + 1)(n + 2)> e.g., if you input 7, then it should print 789. Assume that the
input digit is in range 1-7.
3. Write Python program that accepts marks in 5 subjects and outputs average
marks.
4. Write a short program that asks for your height in centimetres and then
converts your height to feet and inches. (1 foot = 12 inches, 1 inch = 2.54
cm).
6. Write a program to input a single digit(n) and print a 3 digit number created
as <n(n + 1)(n + 2)> e.g., if you input 7, then it should print 789. Assume
that the input digit is in range 1-7.
7. Write a program to read three numbers in three variables and swap first two
variables with the sums of first and second, second and third numbers
respectively.
9. Write a program to read three numbers in three variables and swap first two
variables with the sums of first and second, second and third numbers
respectively.
CH – 8 DATA HANDLING
1. Write a program that reads a number of seconds and prints it in form : mins
and seconds, e.g., 200 seconds are printed as 3 mins and 20 seconds.
[Hint. use // and % to get minutes and seconds]
2. Write a program to take a 3-digit number and then print the reversed
number. That is, if the input given is 123, the program should print 321.
3. Write a program that asks a user for a number of years, and then prints out
the number of days, hours, minutes, and seconds in that number of years.
6. Write a program to find a side of a right angled triangle whose two sides and
an angle is given.
7. Write a program that inputs a string and then prints it equal to number of times
its length, e.g.,
CH – 9 FLOW OF CONTROL
1. A store charges ₹120 per item if you buy less than 10 items. If you buy
between 10 and 99 items, the cost is ₹100 per item. If you buy 100 or more
items, the cost is ₹70 per item. Write a program that asks the user how
many items they are buying and prints the total cost.
(iii) form an integer Y that has the number of digits n at ten's place and the most
significant digit of X at one's place.
(iv) Output Y.
(For example, if X is equal to 2134, then Y should be 42 as there are 4 digits and
the most significant number is 2).
A
A B
A BC
A BCD
A BCDE
9. Write programs using nested loops to produce the following patterns:
0
2 2
4 44
6 666
8 8888
*
* *
***
* *
*
11. Given three numbers A, B and C, write a program to write their values in an
ascending order. For example, if A = 12, B = 10, and C = 15, your program
should print out:
Smallest number = 10
Next higher number = 12
Highest number = 15
12. Write a Python script to input temperature. Then ask them what units, Celsius
or Fahrenheit, the temperature is in. Your program should convert the
temperature to the other unit. The conversions are:
CH – 10 STRING MANIPULATION
2. Write a program which replaces all vowels in the string with '*'.
3. Write a program which reverses a string and stores the reversed string in a
new string.
4. Write a program that prompts for a phone number of 10 digits and two
dashes, with dashes after the area code and the next three numbers. For
example, 017-555-1212 is a legal input. Display if the phone number
entered is valid format or not and display if the phone number is valid or not
(i.e., contains just the digits and dash at specific places.)
5. Write a program to input a line of text and print the biggest word (length
wise) from it.
6. Write a program that should do the following :
7. Write a program that asks the user for a string (only single space between
words) and returns an estimate of how many words are in the string. (Hint.
Count number of spaces)
CH – 11 LIST MANIPULATION
3. Write a program that inputs two lists and creates a third, that contains all
elements of the first followed by all elements of the second.
4. Ask the user to enter a list containing numbers between 1 and 12. Then
replace all of the entries in the list that are greater than 10 with 10.
5. Ask the user to enter a list of strings. Create a new list that consists of those
strings with their first characters removed.
6. Ask the user to enter a list containing numbers, sort the list and print it.
7. Write a program rotates the elements of a list so that the element at the
first index moves to the second index, the element in the second index
moves to the third index, etc., and the element in the last index moves to
the first index.
8. Create the a list containing the squares of the integers 1 through 50.
10. Write a program that takes any two lists L and M of the same size and
adds their elements together to form a new list N whose elements are sums
of the corresponding elements in L and M. For instance, if L = [3, 1, 4] and M
= [1, 5, 9], then N should equal [4,6,13].
11. Write programs as per following specifications:
'''L is a list of numbers. Print a new list where each element is the corresponding
element of list L summed with number num.'''
13. Write a program to read two lists num and denum which contain the
numerators and denominators of same fractions at the respective indexes.
Then display the smallest fraction along with its index.
14. Write a program to display the maximum and minimum values from the
specified range of indexes of list.
15. Write a program to move all duplicate values in a list to the end of the
list.
CH – 12 TUPLES
2. Write a program to input n numbers from the user. Store these numbers in a
tuple. Print the maximum and minimum number from this tuple.
3. Write a program that interactively creates a nested tuple to store the marks
in three subjects for five students, i.e., tuple will look somewhat like :
marks( (45, 45, 40), (35, 40, 38), (36, 30, 38), (25, 27, 20), (10, 15, 20) )
4. Write a program that receives the index and returns the corresponding
value.
5. Write a program that inputs two tuples and creates a third, that contains all
elements of the first followed by all elements of the second.
6. Write a program that interactively creates a nested tuple to store the marks
in three subjects for five students and also add a function that computes
total marks and average marks obtained by each student.
Tuple will look somewhat like :
marks( (45, 45, 40), (35, 40, 38),(36, 30, 38), (25, 27, 20), (10, 15, 20) )
"'Return the length of the shortest string in the tuple of strings str_tuple.
Precondition: the tuple will contain at least one element."'
8. Create a tuple ('a', 'bb', 'ccc', 'dddd', ... ) that ends with 26 copies of the
letter z using a for loop.
9. Given a tuple pairs = ((2, 5), (4, 2), (9, 8), (12, 10)), count the number of
pairs (a, b) such that both a and b are even.
10. Write a program that calculates and displays the mean and mode of a
tuple with numeric elements using statistics module.
CH – 13 DICTIONARIES
1. Write a program to enter names of employees and their salaries as input and
store them in a dictionary.
3. Create a dictionary whose keys are month names and whose values are the
number of days in the corresponding months.
(a) Ask the user to enter a month name and use the dictionary to tell how many
days are in the month.
(d) Print out the (key-value) pairs sorted by the number of days in each month.
Q.7 What are operators? What is their function? Give examples of some unary and binary
operators.
Ans: “Operators are those symbols used with operands, which tells compiler which operation is to be
done on operands.‖ in other words – ―operators are tokens that trigger some
computation/action when applied to variables and other objects in an expression.‖
Operators are of following types:
▪ Unary operators like (+) Unary Plus, (-) Unary Minus, not etc.
▪ Binary Operators like (+) addition, (*) multiplication, and etc.
Q.3 Which of the following are syntactically correct strings? State reason.
(a) ”Python is nice Language”
(b) „He called me “Friend!” when he came‟
(c) “Very Good‟
(d) „This is a good book‟
(e) “Namaste
(f) “I liked „Harry Potter‟ very much”
Ans: (a) Correct (b) Correct (c) Incorrect (d) Correct (e) Incorrect (f) Correct
Q.4 What is the error in following Python program with one statement?
print(“My name is : “, name)
suggest a solution
Ans: Error is : ―name 'name' is not defined‖. And the solution is to declare the variable-name before
this statement.
Ans: Output: 17 5
Q.6 What will be the output of the following code:
Ans: Output: Hari , you are 18 now but You will be 19 next year
Q.7 Write a Program to obtain temperature in Celsius and convert it into Fahrenheit using
formula –
C X 9/5 + 32 = F
Ans:
Q.8 Predict output:
Ans: Output: 4 6 8
Q.9 WAP to read todays date (only date Part) from user. Then display how many days are
left in the current month.
Ans:
Q.10 WAP to print the area of circle when radius of the circle is given by user.
Ans:
Q.11 WAP to print the volume of a cylinder when radius and height of the cylinder is given
by user.
Ans:
Q.12 WAP that asks your height in centimeters and converts it into foot and inches.
Ans:
Ans: 4
4.25
1
4
Q.4 What will be the output of the following ?
(a) bool(0) (b) bool(„0‟) (c) bool(int(„0‟))
(d) bool(str(0.0)) (e) bool(0j) (f) bool(0.0)
Ans: (a) False (b) True (c) False
(d) True (e) False (f) False
Q.5 What will be the output of the following?
(a)87//5 (b)(87//5.0) == (87//5) (c) 87//5.0 (d) 17%5.0
Ans: (a) 17 (b) True (c) 17.0 (d) 2.0
Q.6 int(„a‟) produces error. Why?
Ans: This is because ‗a‘ is an invalid literal for int() with base 10.
Q.7 Write following expressions in Python.
−𝑏±√𝑏2−4𝑎𝑐
(a) 1 𝑏2ℎ (b) 𝑑 = √(𝑥2 − 𝑥1)2 + (𝑦2 − 𝑦1)2 (c) 𝑥 = (d) 𝑎𝑛 × 𝑎𝑚 = 𝑎𝑛+𝑚
3 2𝑎
Ans: -2
6561
Q.5 What will be the output of the following?
Ans: 4.0
Q.6 WAP to take value of x,y,z from the user and calculate the equation 4𝑥4 + 3𝑦3 + 9𝑧2 + 6𝜋
Ans:
Q.7 WAP to take the temperatures of all 7 days of the week and displays the average
temperature of that week.
Ans:
Ans:
Q.6 What is the error in following code. Rewrite the correct code.
Correct
Code:
Q.7 Rewrite the following code fragment using while loop.
Ans:
Q.3 WAP to compute the result when two numbers and one operator is given by user.
Ans:
Q.6 WAP to check whether square root of a given number is prime or not.
Ans:
(ii)
Q.9 WAP to find the average of the list of the numbers entered through keyboard.
Ans:
Q.10 WAP to find the largest number from the list of the numbers entered through
keyboard.
Ans:
Q.11 WAP to find the 2nd largest number from the list of the numbers entered through
keyboard. (This program is from List Chapter)
Ans:
Ans: (a)
(b)
(c)
(d)
Q.3 Which functions would you chose to use to remove leading and trailing white spaces
from a given string?
Ans: Python String strip() function will remove leading and trailing whitespaces. If you want to
remove only leading or trailing spaces, use lstrip() or rstrip() function instead.
Q.4 Suggest appropriate functions for the following tasks –
(a) To check whether the string contains digits.
(b) To find the occurrence a string within another string.
(c) To convert the first letter of a string to upper case.
(d) To convert all the letters of a string to upper case.
(f) To check whether all the letters of the string are in capital letters.
(g) to remove all the white spaces from the beginning of a string.
Ans: (a) isalnum() (b) find() (c) capitalize()
(d) upper() (f) isupper() (g) lstrip()
Q.5 Find the errors -
s=”PURA VIDA”
Print(s[9] + s[9:15])
Ans: Here the error is : Sting index out of range.
Or
This program is for 3 or 4 marks
output
OR
This program is for 3 or 4 marks
output
Or
This program is for 3 or 4 marks
output
Q.7 WAP that creates a third list after adding two lists.
Ans:
Q.2 WAP that creates a third tuple after adding two tuples. Add second after first tuple.
Ans:
Q.3 WAP to calculate the mean of the numbers of the tuple.
Ans:
Q.2 WAP to create a dictionary named year whose keys are month names and values are
their corresponding number of days.
Ans:
Chapter – 1: COMPUTER SYSTEM OVERVIEW
Very Short answer Type Questions
Q.1 What is volatile memory?
Ans: RAM is known as Volatile Memory because when we switch off the computer its data is
vanished.
Q.2 Define each of the following:
(a) byte (b) kilobyte (c) megabyte (d) gigabyte (e) terabyte
Ans: (a) byte: This is the unit of memory in computer. 1 byte = 8 bits
(b) kilobyte: This is the unit of memory in computer. 1 kilobyte = 1024 bytes
(c) megabyte: This is the unit of memory in computer. 1 megabyte = 1024 kilobytes
(d) gigabyte: This is the unit of memory in computer. 1 gigabyte = 1024 megabytes
(e) terabyte: This is the unit of memory in computer. 1 terabyte = 1024 gigabytes.
Q.3 Why is primary memory termed as „destructive write‟ memory but „non-destructive
read‟ memory?
Ans: The primary memory is called destructive write because the data enter here are temporary.
That‘s why your RAM gets cleared after every restart.
Q.4 What is the role of CPU of a mobile system?
Ans: A mobile processor is found in mobile computers and cellphones.
A CPU chip is designed for portable computers, it is typically housed in a smaller chip package,
but more importantly, in order to run cooler, it uses lower voltages than its desktop counterpart
and has more sleep mode capability. A mobile processor can be throttled down to different
power levels or sections of the chip can be turned off entirely when not in use. Further,
the clock frequency may be stepped down under low processor loads. This stepping down
conserves power and prolongs battery life.
Q.5 What is SoC? how it is different from CPU? Why is it considered a better development?
Ans: A system on a chip (SoC) combines the required electronic circuits of various computer
components onto a single, integrated chip (IC). SoC is a complete electronic substrate system
that may contain analog, digital, mixed-signal or radio frequency functions. Its components
usually include a graphical processing unit (GPU), a central processing unit (CPU) that may be
multi-core, and system memory (RAM).
Because SOC includes both the hardware and software, it uses less power, has better
performance, requires less space and is more reliable than multi-chip systems. Most system-on-
chips today come inside mobile devices like smartphones and tablets. These are considered a
better development because of their small size and speed capability.
Q.6 What are various categories of software?
Ans: Software are classified into following categories –
(i) System Software
a. Operating System
b. Language Processor
(ii) Application Software
a. Packages
b. Utilities
c. Customized software
d. Developer Tools
Q.7 What is the difference between an interpreter and a compiler?
Ans: Interpreter: Interpreter is a type of system software that translates and executes instructions
written in a computer program lini-by-line, unit by unit etc. It is slower in execution because
each time when you run the program translation is required.
Compiler: Compiler is another type of system software that translates and executes
instructions written in a computer program in one go. Once compiled program need not to
translate again so it works faster.
Q.23 Discuss the role of utility software in the context of computer performance?
Ans: Utilities are those application programs that assist the computer by performing housekeeping
functions like backing up disk or scanning/cleaning viruses or arranging information etc. its
example is Antivirus software.
Q.24 What is the importance of an OS?
Ans: An operating system is a program which acts as an interface between a user and the hardware.
It manages all the resources of the computer system. It provides and environment to the user
to work with. All the application are installed after the operating system is installed. It manages
memory, processing, storage, memory etc.
Q.25 How are software libraries useful? Name some software libraries of Python.
Ans: A software library is a predefined and available to use, suit of data and programming code in
the form of prewritten code/ functions/scripts/classes etc. that can be used in the development
of the new software programs and applications.
Some software library in python are:
(i) NumPy (numerical Python)
(ii) SciPy (Scientific Python)
(iii) Pandas Library
Q.26 What is the utility of these software?
(a) disk fragmentor (b) backup software
Ans: (a) disk fragmentor: A file is fragmented when it becomes too large for your computer to
store in a single location on a disk. When this happens, your computer splits the file up and
stores in pieces. You can use fragmented files, but it takes your computer longer to access
them.
(b) Backup software: This utility program facilitates the backing-up of disk. Back-up means
duplicating the disk information so that in case of any damage or data-loss, this backed-up data
may be used.