Skip to content

Instantly share code, notes, and snippets.

@pkakelas
Created December 11, 2019 22:05
Show Gist options
  • Save pkakelas/4eeacd23852b726a8ece0f4b94d3ac2f to your computer and use it in GitHub Desktop.
Save pkakelas/4eeacd23852b726a8ece0f4b94d3ac2f to your computer and use it in GitHub Desktop.
#Kailyn Richardson
#12/4/19
#Total Sales for the Week (avg, highest, and total calculated)
weekdays = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday'] # weekdays
def salesEntry(): # this function will return saleslist for whole week
salesList = [] # empty saleslist
print("Enter sales details for each day")
for day in weekdays:
print(day,end=":")
sales = int(input()) # taking input for each day
salesList.append(sales) # adding it to list
return salesList
def printSales(salesList): # this function will show sales details for whole week
print("Details for sale of the week")
day = 0 # variable to keep which day of week is it starting with 0
for sale in salesList:
print(weekdays[day],":",sale)
day += 1
return
def highestSale(salesList): # this function will give day with highest sales
maxsale = 0 # max sale for week
day = 0 # keep check of which day of week is this
for index in range(0, len(salesList)):
if salesList[index] > maxsale:
print(salesList[index])
maxsale = salesList[index] #updating maxsale if greater sale is found
day = index #updating maxsale day
print("Day with highest sale is:",weekdays[day], "with sales = ", maxsale)
return
#The Main Function
def main():
salesList = salesEntry() # taking entries
printSales(salesList) # calling function to print sales
highestSale(salesList) # function to give highest sale
totalSales = sum(salesList) # total sales for week
print("Total sales for the week : ", totalSales)
averageSales = totalSales//5 # average sales for week
print("Average sales for the week : ", averageSales)
main() # calling main function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment