Python Tutorial 10: Homework Solution for Averaging Numbers

preview_player
Показать описание
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:

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
Рекомендации по теме
Комментарии
Автор

Hi Paul, this is Peter from Ghana. I really appreciate your effort in putting these lessons up for free on the internet. God bless you.

peteropokumensahnyante
Автор

Sir i am in my final year of my btech from Northcap University India but i can bet a billion dollar that non of the professor in our college can teach like you, you are avatar of god for me . I with my friend are blessed with your tutorial. Thank you so much sir.

MOHITYADAV-gbfn
Автор

Got lesson 10, max min done. I used IF statements embedded in my FOR Loops and it worked like a BOSS. Thank you again for all the lessons you have created for us. I am 75 years old and these lessons mean allot.

andylaurie
Автор

You are a legend. Hands down, best teacher

UditAmin
Автор

I am legend. There are some things I want to point out though. You do not need 3 for loops for this homework. Use your 'bucket' in the loop adding the grades to your list and add your grades there in the 'bucket'. The range function defaults in steps of 1. So a cleaner code would be: 'for i in range(0, number):'. There is no 'for i in range(0, number, 1):' needed. Nice video though -- All the best from Belgium Philippe

philippeheyvaert
Автор

Wow, I figured out the bucket was going to be a problem and so once I saw the error code I knew. The little knowledge I've been gaining is all thanks to Paul. You are creating so many programmers out of people that would be scared to death of even trying in the first place.

bola
Автор

Have not watched this lesson but wanted to comment on the homework. In the other tutorial I went through before discovering you sent us to replit and on my own I downloaded pycharm. Both gave you packages at your finger tips and you could zombie through averages with the mean package but when you were done you were confused on what you did. After stumbling on the for loops, then watching the solution in lesson 9 I now understand more of the for loops and it was easy to replicate the nuts and bolts to get the average. It is a lot more fun to learn to do than it was to copy to get the job done. Thank You

chalmerditmars
Автор

i AM LEGEND! It doesn't feel like older language loops. I am enjoying more of your most excellent lessons.

cbrombaugh
Автор

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

legendary
Автор

Hello Paul,
Thanks for the effort and love you put into doing these lessons. I made this homework. It was not necessary to use another for loop, since the grades can be compared inside of the second loop.

MrElFRanz
Автор

[ LEGEND ] Did the Homework - Thank you Paul for another great lesson... Did a little research outside the box and came up with an alternate solution that appears to work.
I remember in the Arduino lessons you frowned on using 'i' as a variable so I've been using your suggestion of 'j' to avoid confusion.


numGrades = int(input("How Many Grades Do You Have? "))
grades = []
for j in range(0, numGrades, 1):
grade = float(input("Please Enter Your Grade: "))
grades.append(grade)
avGrades = sum(grades) / len(grades)
print("Your Grades Are: ")
for item in grades:
print(item)
print("Your Average Grade is: ", avGrades)
print("Thats All Folks")

justmc
Автор

Awesome lesson 👍👍👍
I'm loving this whole format 👍

bigbogeyface
Автор

Hello Paul,
Thanks,
I made it with only two for loops, here it is:
numGrades=int(input('How Many Grades Do You Have? '))
Grades=[ ]
Total=0.0
for i in range(0, numGrades, 1):
grade=float(input('Please Input Your Grade: '))
Grades.append(grade)
print(Grades)
Total=Total+grade
for i in range(0, numGrades, 1):
print(Grades[i])
Average=Total/numGrades
print('Your Average Is ', Average)

ziadahmad
Автор

Best teacher ever specially when you talk about Black cup of coffee no sweet none needed

kjynlhj
Автор

Hey Paul, I was able to do the homework all on my own. Hardest part was adding up the numbers in the array! I then realized that it worked if you summed all of the numbers in a For loop! Thanks for the great lessons!

adirajchalotra
Автор

I AM LEGEND and I AM LEGEND! Had to say it twice because I was so happy that I figured out Lesson #9 homework. Took a whole lot of thinking but I did it. Thanks again Maestro! God bless!

charlielowell
Автор

folded, folded, folded. Started from lesson 1 again... LEGEND

jaxonvvv
Автор

I am MYTH...or at least a fireside children's story...Not quite a Legend, not quite a Lawn Chair.
I struggled for quite a while and ended up with everything except how to add the grades. Instead of bucket I used avGrade but all I had was: avGrade=grades/numGrades.
I had tried appending grades to avGrade and putting different variables in range...
I understand now, Thanks Paul!
I added a couple if statements to it to make up for my failure,
if Average <=85:
print('You need more Jet Fuel!')
if Average>=85:
print('You are fully fuelled!')

kriegschwert
Автор

I figured it out! I AM LEGEND!! 😄

I started the variable 'highGrade' at 0, and the variable 'lowGrade' at 100. I used two conditions to compare the input value; the first comparing if the input number is greater than highGrade, and the second comparing if the number is less than lowGrade. As each consecutive number is typed in, depending on the condition met, it updates either highGrade, or lowGrade, only storing the max and min values encountered. This was the only way I found I could work around this problem!

FF
Автор

I AM LEGEND. I Really appreciate the huge effort and energy you put into these lesson. So hooked you up on Patreon. For the average i discovered the function : sum(grades) and then just divided with number of grades.

jabber