Student Details ( Student should fill the content)
Name
Student ID ICBT ID :
Batch No
Scheduled unit details
Unit code C006
Unit title Programming with Python
Assignment Details
Nature of the Assessment Examination
Topic of the Case Study GIVEN
Learning Outcomes covered YES
Word count Examination duration : 3 hours
Due date / Time As communicated in the assessment plan
Declaration
I certify that the attached material is my original work. No other person’s work or ideas have
been used without acknowledgement. Except where I have clearly stated that I have used
some of this material elsewhere, I have not presented it for examination / assessment in any
other course or unit at this or any other institution
Signature Date
Result (Assessor use only)
Marks by 1st Assessor Name & Signature of the 1st Agreed Mark
Assessor
Marks by IV: Name & Signature of the IV
For Office use only (hard copy assignments)
Receipt date Received by
SECTION I – Programming Logic
Answer all questions Duration: 1 ½ hours
Q1.
a. Write the output of the following code segment;
i. age=20
if age <= 15: Output:
print (“Child”)
else:
print (“Adult”)
ii. num=1 Output:
while num <10
print (num)
num = num + 2
(6 marks)
b. How many times will the following ‘while’ loop execute?
count = 20
while count>=2
count=count-4
end while
_____________________________________________________
(2 marks)
c. Consider the following assignment statement in a program segment that are executed
in the given order
day = 22
today = 25
day = today
What is the value of day? ______________________________________
2
(2 marks)
3
Q2).
Draw a flow chart for a program to input any number and display whether it is an odd number
or an even number.
(10 marks)
4
Q3).
Draw a flow chart for a program that accepts students’ marks for a subject as user input. The
program should output the grades based on the criteria given below.
If Marks greater than 75
Grade A
If Marks between 74 – 60
Grade B
If Marks between 59 – 50
Grade C
If Marks between 49 – 40
Grade S
If Marks less than 40
Grade F
(15 marks)
5
Q4).
Using a while loop input 5 marks of a student and calculate the student's total and average.
(15 marks)
6
SECTION II – Python Programming
Answer all questions Duration: 1 ½ hours
Q1). Answer the following questions using the given picture
a. What would the above Python program display first, when you run the code?
______________________________________ (3 marks)
b. What would the output of the above Python code based on the inputs given?
______________________________________ (3 marks)
c. How many variables are used in the above code? What are they?
______________________________________
______________________________________
______________________________________ (6 marks)
d. Name one data type used in the above program
______________________________________ (3 marks)
7
Q2)
Write a Python code for a program to accept Basic Salary of an employee as user input. The
program should calculate and display the Net Salary. Use the following criteria for the
calculation.
If Basic Salary is less than 15000;
Bonus Amount = 10% of Basic Salary.
If Basic Salary is in between 15000 and 25000;
Bonus Amount = 15% of Basic Salary.
If Basic Salary is greater than 25000;
Bonus Amount = 20% of Basic Salary.
Net Salary = Basic Salary + Bonus Amount
(15 marks)
Q3).
Write a Python program that where takes 5 students’ marks for the math subject as user input,
your program should calculate and print the total and the average for the subject.
(10 marks)
Q4).
Create a python program to accept present meter reading of power and previous reading of
power as user input. Your program should calculate the electricity bill based on the following
rates.
If the Number units used are less than 30 LKR 1.5
If the Number units used are less than 90 LKR 2.5
If the Number units used are more than 90 LKR 4.5
(10 marks)