Computer ScienceA1 MID TERM 2022 23 MS
Computer ScienceA1 MID TERM 2022 23 MS
General Instructions:
Ans : b) 1st_string
Q3. Consider the declaration L = '3.14+20j'. What will be the data type of L? (1)
a) list
b) tuple
c) dictionary
d) String
Ans : d) String
Q4. Which of the following symbols is used in python for single line comment? (1)
a) / b) /* c) // d) #
Ans. #
Ans : b) 10
1
Q6. Select all options that print : hello-how-are-you
a) print(‘hello’, ‘how’, ‘are’, ‘you’)
b) print(‘hello’, ‘how’, ‘are’, ‘you’ + ‘-‘ * 4)
c) print(‘hello-‘ + ‘how-are-you’)
d) print(‘hello’ + ‘-‘ + ‘how’ + ‘-‘ + ‘are’ + ‘you’)
Ans : c) & d)
Ans : a) string
Ans : a) Two
a) 432
b) 342
c) 164
d) 102
Q11. How does the computer understand a program written in high level language? (2)
Ans. Humans are able to write programs in high-level language while computers can
understand only machine language. so with the help of language translators (Compiler or
Interpreter) programs written in HLL can be converted into machine language which is
understood by computer.
Q12. What is the need for RAM? How does it differ from ROM? (2)
2
Ans. RAM is used to store data temporarily while the computer is working. Whenever the
computer is started or a software application is launched, the required program and data
are loaded into RAM for processing.
RAM ROM
It stands for Random Access Memory It stands for Read Only Memory
It is volatile in nature It is non volatile
It stores data temporarily It stores instruction permanently
Q13 Name the software required to make a computer functional. Write down its two primary
services. (2)
Ans. The software required to make a computer functional is Operating System (OS). It’s two
primary services are :
Memory management : It manages Primary or main memory of a computer system.
Device Management : It interacts with the device driver and the related software for a
particular device.
Q14. Differentiate between proprietary software and freeware software. Name two software for
each type. (2)
Ans.
Proprietary Software Freeware Software
Q16 a) Derive a Boolean expression for the output F for the logic circuit given shown below :
(2x2=4)
i)
Ans. (A’B’+CD)’
ii)
Ans. (A’.(A+B))
ii) (X+Y).(X+Z)
Q17. What is the difference between interactive mode and script mode in Python? (2)
4
Ans. Script Mode, is used when the user is working with more than one single code or a
block of code. Interactive mode is used when an user wants to run one single line
or one block of code.
Ans.a) False
b) 22
Q19. What do you mean by data types? What are Python’s built-in core data types? (2)
Ans. Python Data Types are mainly of 3 types: Boolean, integer, and string. These may also be
called the core data types in Python.
Q20. What is the difference between implicit and explicit conversion? (2)
Ans. Implicit Type Conversion is automatically performed by the Python interpreter. Python
avoids the loss of data in Implicit Type Conversion. Explicit Type Conversion is also called
Type Casting, the data types of objects are converted using predefined functions by the
user.
Q21. What are string literals? How many types of string literals are there? (2)
Ans. A string literal is a sequence of zero or more characters enclosed within single
quotation marks. The following are examples of string literals: 'Hello, world!' 'He
said, "Take it or leave it."' In python we have two types of string literals namely single
line strings and multiline strings.
Q22. A school conducts 3 weekly tests of 30 marks each and a term exam of 100 marks. To
calculate the aggregate percentage of marks obtained by a student, calculations are done as
follows:
Aggregate Percentage = (weekly test total)/3+70% of term exam.
Write a Python script to calculate and display the aggregate percentage of a student after
taking the marks of the student in the three weekly tests and the term exam. (3)
5
Q23. Write a program to enter a number and print whether the number is positive, negative or
zero. (3)
Q25. Write a program to input two integers x & n and then print the sum of the following series:
(3)
1+x+x2+x3+x4+.............xn
6
Ans. x=int(input(“Enter value of x”)
n=int(input(“Enter value of n”)
s=1
for i in range(n):
sum=sum+pow(x,i)
print(“sum=”, s)
Q26. Identify errors in the following code and rewrite the code by underlining the corrections.
(3x2=6)
a) A=B=12/5
if A!=b
print"Not equal"
else print"Equal"
Ans. A=B=12/5
if A!=B:
print("Not equal")
else:
print("Equal")
c) x = input(“Enter value”)
for k in range[0,20]
Print(x+k)
a) year=2000 (1)
7
if year%100!=0 and year%4==0 or year%400==0:
print("Lp")
else:
print("Not Lp")
Ans. Lp
Ans. 2#3@4#5#6#7@7
c) x=5 (2)
for k in range(0,10) :
if x==k:
print(x+k)
else:
print(x-k)
Ans : 5
4
3
2
1
10
-1
-2
-3
-4
Ans: Bye 1
Bye 2
Bye 4
Bye 5
Bye 7
Bye 8
Bye 10
Bye 11
8
Bye 13
Bye 14
Bye 16
Bye 17
Bye 19
e) x=6 (2)
for i in range(x):
if x==5:
break
print("H")
print(x)
Ans : H
H
H
H
H
H
6