Python Tutorial 10: Homework Solution for Averaging Numbers

Spread the love



You guys can help me out over at Patreon, and that will help me keep my gear updated, and help me keep this quality content coming:

https://www.patreon.com/PaulMcWhorter

In this video we show step-by-step instructions on how to write a python program for averaging numbers. I do not assume you are an expert, so these lessons are designed for complete beginners.
#Python
#Lessons
#Programming

source

2 thoughts on “Python Tutorial 10: Homework Solution for Averaging Numbers

  • April 28, 2021 at 5:59 pm
    Permalink

    I'm in Lesson 51 now in Arduino tutorial and I'm absolutely love you, they are great!

    Reply
  • April 28, 2021 at 5:59 pm
    Permalink

    myGrades = int(input('Please input the Number of Grades: '))
    myValues = []
    myOutput = ''
    if myGrades < 0:
    exit('The Grades Count should be over 0')

    for i in range(myGrades):
    myNumber = float(input('Please input the '+str(i+1)+'/'+str(myGrades)+' Number: '))
    myValues.append(myNumber)
    myOutput = myOutput + str(i+1)+'. Position: ' + str(myNumber) + 'n'

    print(myOutput+'Average: '+str(round(sum(myValues,0)/myGrades,2)))

    Output:
    Please input the Number of Grades: 2
    Please input the 1/2 Number: 5
    Please input the 2/2 Number: 10
    1. Position: 5.0
    2. Position: 10.0
    Average: 7.5

    Reply

Leave a Reply

Your email address will not be published.