*8997913024*
PROGRAMMING IN PYTHON DCS1
July/August 2023
3 hours
You must answer on the provided answer
booklet.
You will need:
INSTRUCTIONS
● There are three sections in this paper,
● Answer ALL questions from Section A.
● Answer ALL questions from Section B.
● Answer TWO question from Section C
● Use a black or dark blue pen. You may use an HB pencil for any diagrams or graphs.
● Write your names, programme and student number on every page of the answer booklet.
● Write your answer to each question in the space provided.
● Do not use an erasable pen or correction fluid.
● Do not write on any bar codes.
● You should show all your working and use appropriate units.
INFORMATION
● The total mark for this paper is 65.
● The number of marks for each question or part question is shown in brackets [ ].
This document has 4 pages. Blank pages are indicated.
© PRI 2023 [Turn over]
SECTION (A)
10 marks, Answer all
1. Python is a ___object-oriented programming language.
A. Special purpose B. General purpose
C. Medium level programming language D. All of the mentioned above
2. Amongst which of the following is / are the application areas of Python
programming?
A. Web Development B. Game Development
C. Artificial Intelligence and Machine Learning D. All of the mentioned above
3. Float type of data type is represented by the float class.
A. True B. False
4. The % operator returns the ___.
A. Quotient B. Divisor
C. Remainder D. None of the mentioned above
5. What will be the output of the following Python code?
a=7
if a>4: print("Greater")
A. Greater B. 7 C. 4 D. Lesser
6. What will be the output of the following Python code?
i=5
if i>11 : print ("i is greater than 11")
A. No output
B. Abnormal termination of program
C. Both A and B
D. None of the mentioned above
7. The for loop in Python is used to ___ over a sequence or other iterable objects.
A. Jump
B. Iterate
C. Switch
D. All of the mentioned above
8. The continue keyword is used to ___ the current iteration in a loop.
A. Initiate
B. Start
C. End
D. None of the mentioned above
9. Amongst which of the following is / are true about the while loop?
A. It continually executes the statements as long as the given condition is true
B. It first checks the condition and then jumps into the instructions
C. The loop stops running when the condition becomes fail, and control will move to the
next line of code.
D. All of the mentioned above
10. What will be the output of the following Python code?
for i in range(6):
print(i)
A. 0 B. 1 C. No Output D. None of them
1 2
2 3
3 4
4 5
5
SECTION (B)
(25) Marks, Answer All Questions from this section
1. Consider the following code segment and identify what will be the output of
given Python code? Explain what the if statement does from the given code below
give the variables values for illustration. [5 marks]
a = int(input("Enter an integer: "))
b = int(input("Enter an integer: "))
if a <= 0:
b = b +1
else:
a=a+1
2. What will be the output of the following Python code?. And Explain the Logic of
the if statement. [5 marks]
num = 10
if num > 0:
print("Positive number")
elif num == 0:
print("Zero")
else:
print("Negative number")
3. Is it TRUE that in Python, an else statement comes right after the block after 'if'?
if yes explain your answer with the help of the syntax. [5 marks]
4. The following synatx is used to define what kind of sequence. And distinguish it
with a LIST. Give a syntax. [10 marks]
d={
<key>: <value>,
<key>: <value>,
.
.
.
<key>: <value>
}
Section C
(30) marks, Answer TWO Questions from section C
5. Write a Python program to check whether the given integer is a multiple of 2 [15
marks]
6. Write a Python code that calculates a grade of a Student, when a mark is entered
by the user in the system. [15 marks]
7. Given a rectangle below, write a python program that allows a user to enter a and
b and calculates the diameter of a rectangle. [15 marks]
- formula: diameter = √ (a ¿ ¿ 2+b2 ¿ )¿ ¿