# When you have to send a gift to your friend or relative living in another city, what do you do?
# One uses the courier service in such scenarios. Can you name some of the courier companies?
# Lets create a program that will help the courier services personnel, when they accept parcels.
# Are you ready?
'''Task 1: Courier at your Service'''
print("**** Task 1: ****")
print()
# You work with DTDC Courier Services.
# When accepting the parcel from the customer, you need to ensure that the length and width is not more than 60cm.
# The total weight of the parcel cannot be more than 5 kg
# If any of the above requirements are not met, the parcel needs to be rejected.
# And not more than 2 parcels from a customer can be accepted.
print("Welcome to the DTDC Courier service.\n")
num = int(input("How many packages are you shipping today?"))
if num > 2:
print("The maximum amount of packages you can ship is two per customer. Try again please.\n")
else:
for p in range(1,num+1):
print("Now tell me the width (cm), length (cm), and weight (kg) for your package in that order one by one.\n")
for i in range(1,4):
if i == 1:
dim = int(input("Enter the first thing."))
if dim > 60:
print("Sorry, it is too big. Try again later.")
break
else:
continue
if i == 2:
dim = int(input("Enter the second thing."))
if dim > 60:
print("Sorry, it is too big. Try again later.")
break
else:
continue
if i == 3:
dim = int(input("Enter the third thing."))
if dim > 5:
print("Sorry, it is too big. Try again later.")
break
else:
print("You have successfullly shipped your package.")
'''Task 2: At the Dairy Farm'''
print("**** Task 2: ****")
print()
# A farmer records the milk production of a herd of 3 cows.
# The volume of milk from each cow is recorded only once a day and placed in a container
# At any point, if the total volume of milk crosses 50 litres, then print a message to request for a new container and don't take any further input
# You decide to write a program to help the farmer.
import random
milk = 0
tot = 0
time = 0
cows = 0
while tot <= 50:
cow = random.randint(1,4)
time += 1
milk = cow * 3
tot += milk
if tot>50:
break
else:
continue
print(f"\n Your cows have finished the first container in {time} hours, we will need a new container because each of your cows have been producing an average of {tot/time/3} liters of milk per hour.")
'''Task 3: Below or Above the grade'''
print("**** Task 3: ****")
print()
# You are the English teacher for Grade 5.
# Your class consists of 15 students. You need to record the marks scored by each student.
# As you are recording the marks for the subject, you need to calculate the average. If the average at any point goes below 50 , you need to display a message that the marks need to be recalculated and start again.
# To make things easy, you decide to write a Python program. # So go ahead!!
import random
restart = True
while restart:
count = 0
total = 0
restart = False
while count < 15:
student_mark = random.randint(1, 100)
count += 1
total += student_mark
# Calculate the real current average
current_average = total / count
# Check if the running average drops below 50
if current_average < 50:
print(f"Student {count} scored {student_mark}. Running average dropped to {current_average:.2f}!")
print("Calculations must be done again!!!\n")
restart = True
break
if not restart:
final_average = total // count
print(f"The total average is {final_average} out of one hundred")
'''Task 4: What's the score'''
print("**** Task 4: ****")
print()
# You are the assistant professor, helping in calculating the test scores of students.
# You write a program that will:
# - Ask for the number of students whose score needs to be taken
# - You will keep a counter for the number of pass scores. If the score is between 40 and 100, then it is considered as a pass score
# - If the counter for pass scores is lesser than half of the total number of students, your program will display a message that the total score cannot be displayed.
# - If the counter for pass scores is greater than the half of the total number of students, your program will display the total score.
total_students = int(input())
pass_count = 0
total_score = 0
for _ in range(total_students):
score = float(input())
total_score += score
if score >= 40 and score <= 100:
pass_count += 1
if pass_count >= (total_students / 2):
print(total_score)
else:
print("The total score cannot be displayed.")
'''Wonderful! You have mastered creating multiple ifs within a while loop and set for another challenge. Way to go!!'''
To embed this project on your website, copy the following code and paste it into your website's HTML: