Added main files and readme.

This commit is contained in:
Ray 2022-09-18 14:08:45 +10:00
commit ebbeedb47a
2 changed files with 43 additions and 0 deletions

10
README.md Normal file
View File

@ -0,0 +1,10 @@
# Marks
A python program I "repaired" as part of an assessment while studying at TAFE NSW.
All fixes towards the code have been noted in the comments.
Simple score calculator which calculates the total and average based on the scores provided. The scores must be between 0 and 100.
I fixed issues ranging from simple mistakes such as mismatched variable names and adding int( onto certain commands to creating new sections of code entirely which involved loops.
© Rayyan Hodges, TAFE NSW, Gelos Enterprises, 2022

33
marks.py Normal file
View File

@ -0,0 +1,33 @@
active = False
while active == False:
print("please enter your 5 marks below")
#read 5 inputs (missing int( before (input)))
mark1 = int(input("enter mark 1: "))
mark2 = int(input("enter mark 2: "))
mark3 = int(input("enter mark 3: "))
mark4 = int(input("enter mark 4: "))
mark5 = int(input("enter mark 5: "))
#determine if scores are between 0 and 100, if not, reload program from beginning. (this was missing in the initial version)
if mark1 < 0 or mark1 > 100 or mark2 < 0 or mark2 > 100 or mark3 < 0 or mark3 > 100 or mark4 < 0 or mark4 > 100 or mark5 < 0 or mark5 > 100:
print("error: marks must be between 0 and 100")
else:
active = True
#create array/list with five marks
marksList = [mark1, mark2, mark3, mark4, mark5]
#print the array/list (simply added an asterisk before marksList to create a mathematical expression)
print(*marksList)
#calculate the sum and average
sumOfMarks = sum(marksList)
averageOfMarks = sum(marksList)/5
#display results
print("The sum of your marks is: "+str(sumOfMarks))
print("The average of your marks is: "+str(averageOfMarks))