CLO3-Part2-Lab - Solutio
CLO3-Part2-Lab - Solutio
ACTIVITY CLO3_2
CHAPTERS:
TOOLS: PYTHON/REPL.IT
PROCEDURE:
1
EXERCISE 1-APPLY
The appliances section in Carrefour add a delivery charge (per items) onto the appliances bill
as follows:
Items Additional
delivery charge
per item
Up to 2 70
3 to 5 50
6 to 7 35
More than 7 30
Write a python program that asks the user to enter the number of items then calculates and
displays the total delivery charge that the client will need to pay.
Solution
Model answer
if (Items<1):
print ("Error, Items must be 1 and above !!")
elif (Items < 3):
Charge = Charge + (Items * 70)
elif (Items < 6):
Charge = Charge + (Items * 50)
elif (Items < 8):
Charge = Charge + (Items * 35)
else:
Charge = Charge + (Items * 30)
2
EXERCISE 2 - APPLY
Write a program to read the number of computers that need to service and calculate the
service charge as in below table. See screen shot below.
Screenshot
Solution
charge=0
3
EXERCISE 3 - APPLY
AD parks sell entry ticket at the cost of dirhams 200. They give discount based on number of
tickets bought as shown in below table.
Write a Python program that read number of ticket purchased, calculate and display the total
price before the discount, discount amount and final price after discount.
Screenshot
Solution
4
print("Total amount before discount is", charge)
print("Discount at", rate, "% is", discount)
print("Final price after discount is", discounted_price)
EXERCISE 4 - APPLY
Write a Python program that read number and display the number with the suffix based on
the last digit of the number as shown below.
Note: You can use modules operator to get the last digit of a number.
Solution
last_digit = n % 10
if (last_digit == 1):
print(n, "-st")
elif (last_digit == 2):
print(n, "-nd")
elif (last_digit == 3):
print(n, "-rd")
else:
print(n, "-th")
5
EXERCISE 5 - APPLY
Write a program to read the heights of 3 persons, then find and display the tallest height. See
screen shot below.
Screenshot
Solution
6
height1= float(input("Enter the first person height: "))
height2= float(input("Enter the second person height: "))
height3= float(input("Enter the third person height: "))
max=0
if (height1>height2):
if (height1>height3):
max =height1
else:
max =height3
else:
if (height2>height3):
max =height2
else:
max =height3
AUTHOR
AIM
CASE DESCRIPTION
7
QUESTIONS
1. Question 1 description
2. Question 1 description
3. Question 3 description
4. Question 4 description
5. Question 5 description
6. Question 6 description
Green color means these questions were solved in the previous activities
Black color indicates that the question be will treated in the current activity
Gray color means that these questions will be investigated during the upcoming activities