Assignment 7.py - Michelle Gong Section 03 This program uses function definitions to analyze the monthly sales figures for a division 1 Returns user

Assignment 7.py - Michelle Gong Section 03 This program...

This preview shows page 1 - 2 out of 3 pages.

# Michelle Gong # Section 03 # This program uses function definitions to analyze the monthly sales figures # for a division # 11/25/19 # 1 # Returns user input in a certain format and puts them into a new list def user_format(sales): new_sales = [] for sale in sales: # assumes user input is >= 0.00 new_sales.append('$' + format(sale, ',.2f')) return '{' + ', '.join(new_sales) + '}' # 2 # Returns the highest number in the list def max2 (sales): m = sales[0] for sale in sales [1:]: # compares each sale with current largest if sale > m: # updates largest number to current one m = sale return m # 3 # Returns the lowest number in the list def min2 (sales): m = sales[0] for sale in sales [1:]: # compares each sale with current smallest if sale < m: # update smallest number to current one m = sale return m # 4 # Returns the total monthly sales for the company def sum2 (sales): s = 0 for sale in sales: # accumulates each sale into the sum s += sale return s # 5 # Returns average of all the numbers in the list def average (sales): s = sum2(sales) # calculates sum average = s / len(sales) return average # 6
Image of page 1
Image of page 2

You've reached the end of your free preview.

Want to read all 3 pages?

  • Spring '16
  • goldner barbara

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern

Stuck? We have tutors online 24/7 who can help you get unstuck.
A+ icon
Ask Expert Tutors You can ask You can ask ( soon) You can ask (will expire )
Answers in as fast as 15 minutes
A+ icon
Ask Expert Tutors