C006-Programming-Python[1]
C006-Programming-Python[1]
Name
Student ID ICBT ID :
Batch No
Assignment Details
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
Marks by 1st Assessor Name & Signature of the 1st Agreed Mark
Assessor
Q1.
a. Write the output of the following code segment;
i. age=20
if age <= 15: Output:
print (“Child”)
else:
print (“Adult”)
(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
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)
______________________________________ (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.
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.
(10 marks)