Programming-Challenges/06 Returning Values/exercise-01.py

33 lines
1.2 KiB
Python

def get_name():
""" ask for a name and return it """
name = input("What is your name? ")
return name
def get_cs_teacher_name():
""" ask for a students cs teacher's name and return it """
name = input("What is your CS teacher's name? ")
return name
def average_homework():
""" get the score out of 10 for the last 4 homework assignments and average them """
test_scores = []
for i in range(4):
score = int(input("What is the score for assignment " + str(i+1) + "? "))
test_scores.append(score)
return sum(test_scores)/4
name = get_name()
teacher_name = get_cs_teacher_name()
average = average_homework()
# if average >= 8: well done {name}, {teacher_name} is very pleased with your effort
# if average >= 6 > 8: A good effort {name}, {teacher_name} thinks you should check your work carefully
# if average >= 5: {name} this is very poor, {teacher_name} has asked you to try harder
if average >= 8:
print(f"Well done {name}, {teacher_name} is very pleased with your effort")
elif average >= 6:
print(f"A good effort {name}, {teacher_name} thinks you should check your work carefully")
elif average >= 5:
print(f"{name} this is very poor, {teacher_name} has asked you to try harder")