Python Tutorial 10: Homework Solution for Averaging Numbers

  Рет қаралды 23,663

Paul McWhorter

Paul McWhorter

3 жыл бұрын

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:
/ 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

Пікірлер: 320
@peteropokumensahnyante7499
@peteropokumensahnyante7499 2 жыл бұрын
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.
@MOHITYADAV-gb6fn
@MOHITYADAV-gb6fn 3 жыл бұрын
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.
@drzwithcrow6075
@drzwithcrow6075 Жыл бұрын
I taught Chemistry at a uni. I tried to be different to most of the other lecturers in that it seemed to me that their main purpose was to demonstrate that they knew more than the students. Too bad if the students didn't understand - that just proved that the lecturers were correct: they knew more. And that is why learning here is such a breath of fresh air!
@andylaurie326
@andylaurie326 3 жыл бұрын
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.
@paulmcwhorter
@paulmcwhorter 3 жыл бұрын
Fantastic!
@UditAmin2510
@UditAmin2510 3 жыл бұрын
You are a legend. Hands down, best teacher
@legendary9529
@legendary9529 3 жыл бұрын
I'm in Lesson 51 now in Arduino tutorial and I'm absolutely love you, they are great!
@cbrombaugh
@cbrombaugh 3 жыл бұрын
i AM LEGEND! It doesn't feel like older language loops. I am enjoying more of your most excellent lessons.
@MrElFRanz
@MrElFRanz 3 жыл бұрын
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.
@bola5671
@bola5671 2 ай бұрын
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.
@chalmerditmars7037
@chalmerditmars7037 Жыл бұрын
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
@bigbogeyface
@bigbogeyface 3 жыл бұрын
Awesome lesson 👍👍👍 I'm loving this whole homework/solution/homework/solution format 👍
@paulmcwhorter
@paulmcwhorter 3 жыл бұрын
Great to hear!
@opalprestonshirley1700
@opalprestonshirley1700 3 жыл бұрын
I finished the max and min grades. Loving it. Thanks, Paul.
@paulmcwhorter
@paulmcwhorter 3 жыл бұрын
Excellent Opal.
@santiagorussomartinez390
@santiagorussomartinez390 2 жыл бұрын
Hi Paul! I think this is the first time i comment in one of your videos. Yesterday i completed your arduino lessons and now i'm starting with the Python ones. Just wanted to say that i'm grateful for what you do, these are super cool and entretaining lessons and you are an amazing teacher. Btw, i use a bit of milk and sugar in my coffee,(sorry hehe please don't ban me 😰) Greetings from Argentina :)
@justmc62
@justmc62 Жыл бұрын
[ 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")
@dsrawat2046
@dsrawat2046 3 жыл бұрын
Your way of explanation is excellent, its give me a great help, love you sir
@SaiyanCat
@SaiyanCat 2 жыл бұрын
did it on my own, couldn't have done it without your arduino lessons.
@okieinexile
@okieinexile 3 жыл бұрын
You teach your audience well. They will be well prepared when they go to the next level.
@alfredcheung6704
@alfredcheung6704 2 жыл бұрын
Thank you Paul. The video is really helpful!👍
@wieselzk2
@wieselzk2 3 жыл бұрын
Took me more than an hour but I made it, you're an awesome teacher, keep it up!
@paulmcwhorter
@paulmcwhorter 3 жыл бұрын
Great job!
@darthdaenerys
@darthdaenerys 2 жыл бұрын
I'm a LEGEND😀 Thanks Paul for all your amazing lessons
@pudgepatenaude3481
@pudgepatenaude3481 3 жыл бұрын
I was indeed able to complete the assignment. I am learning from the "Legend" thank you sir!
@philippeheyvaert3742
@philippeheyvaert3742 8 ай бұрын
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
@R3b0rNz
@R3b0rNz 3 жыл бұрын
Thank you Paul, really enjoy watching your videos. I learnt a lot from you
@paulmcwhorter
@paulmcwhorter 3 жыл бұрын
Glad you like them!
@soundarrajankannan7692
@soundarrajankannan7692 3 жыл бұрын
You are a great teacher. I came here from your new arduino tutorials. I finished my homework. I came here to see your way of solving.
@paulmcwhorter
@paulmcwhorter 3 жыл бұрын
Wow, thanks!
@shuttlepodone1707
@shuttlepodone1707 3 жыл бұрын
I am legend! I think I am getting the hang of Python basics slowly but surely but only due to your wonderful teaching method!
@paulmcwhorter
@paulmcwhorter 3 жыл бұрын
Great to hear!
@preying_mantid
@preying_mantid 3 жыл бұрын
I was able to do the hw for next week with just the addition of 2 print lines. Thanks for the lesson, Paul! These lessons in tandem with other tutorials have been immensely helpful.
@paulmcwhorter
@paulmcwhorter 3 жыл бұрын
Fantastic!
@preying_mantid
@preying_mantid 3 жыл бұрын
@@paulmcwhorter I saw you reply to another comment saying that you would prefer to see us do it with for loops instead of min(), max() functions. I wasn't able to properly figure out how to do the first hw assignment (total = total+Grades[i]), but I went back and figured out on my own how to do the high/low grades with for loops. Thanks for challenging me to think differently!
@adirajchalotra4916
@adirajchalotra4916 Жыл бұрын
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!
@paulmcwhorter
@paulmcwhorter Жыл бұрын
Excellent!
@jabber2824
@jabber2824 Ай бұрын
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.
@paulmcwhorter
@paulmcwhorter Ай бұрын
Excellent, Thanks!
@fransvanenschot3286
@fransvanenschot3286 2 жыл бұрын
Hi Paul, Thanks for your excellent tutorials. aim agree that it is very necessary that you doing the homework. aim already programming already over 50 years, and have learned and used in that time all maybe more than 30 different programming languages, and i know that it is a must to do the homework also when it's look easy in the first instance. most of the time when i started with a test i made faults, and then your started really with learning the new language, and it is nice too make the first programs by your self also. Thanks for all the good work i will use Python in combination with Arduino. In the past i have used html for that
@davidschnider1297
@davidschnider1297 Жыл бұрын
Hey Paul... definitely NOT boring. .. these lessons are both FUN and CHALLENGING .. even though I learned to code - using some of the same exercises 40+ years ago.. via FORTRAN, coded using PUNCH CARDS..
@codecage9333
@codecage9333 3 жыл бұрын
I am legend! Putting the sum of the grades, your bucket, in the for loop that printed the list of grades works as well and saves an additional for loop.
@graydhd8688
@graydhd8688 Жыл бұрын
I folded like a cheap walmart lawn chair on this one unfortunately, felt I was getting close but I gave it a good effort. When I stumble with your assignments and have to watch your solutions though I come out stronger and use that knowledge to create a similar assignment that's just different enough I have to think about it to finish. I've been doing this for the assignments I crumble under before moving to your next lesson!
@charlielowell4077
@charlielowell4077 2 жыл бұрын
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!
@paulmcwhorter
@paulmcwhorter 2 жыл бұрын
Great job!
@ecassar1975
@ecassar1975 3 жыл бұрын
I am legend. My homework is almost a photocopy of your code. You are the best teacher!!!
@paulmcwhorter
@paulmcwhorter 3 жыл бұрын
Wow, thanks!
@nikhileshbhaskar5163
@nikhileshbhaskar5163 3 жыл бұрын
you are a best tutor for beginners
@RobVollmar
@RobVollmar 2 жыл бұрын
I was feeling pretty downtrodden after failing to figure out two assignments in a row but I nailed the final one of this leson. I AM LEGEND!
@paulmcwhorter
@paulmcwhorter 2 жыл бұрын
If it was easy it would not feel so good when you get one done. LEGEND!
@pennyshen5269
@pennyshen5269 Жыл бұрын
i was so excited that so many people were learning python togerther here.i m new in this area ,but rally gained a lot of fun!thank u paul!😀🥰 here are some things i leared from this might help my learning friends better understanding this homework:(some mistakes i made ) 1.index is really important! i only made one loop at the fisttime so i cant get the proper answer ,if i input 'i have 4 grades ,(1,2,3,4)'.the sum will be like 6. i think it because the computer start to count from 0 here ..0.1.2 so the sum=1+2+3=6 2.bucket=0 if u dont do it ,it wont work,like paul said . hope its helpful for u guys🥺👀
@kme8134
@kme8134 Жыл бұрын
Thanks Paul! I have learned so much here. One thing I found, that I am sure you are aware of, is that you can say sum(array) to get the total sum of values inside the array.
@smokingunnz
@smokingunnz 3 жыл бұрын
I am legend. Really appreciate this fun course and enjoy your 'jet-fuelled' teaching.
@paulmcwhorter
@paulmcwhorter 3 жыл бұрын
Much appreciated!
@blinkdrs
@blinkdrs 2 жыл бұрын
I did manage to achieve the desired results for averaging the grades, but unfortunately my way was alot more complicated! Your way was definitely easier than I made it. Thanks for these lessons Paul!
@user-kj7yn2lh8j
@user-kj7yn2lh8j 2 жыл бұрын
Best teacher ever specially when you talk about Black cup of coffee no sweet none needed
@fatherloz2800
@fatherloz2800 2 жыл бұрын
Thanks Paul ! Seems i am a legend ! :) hehe, Did some searching and ended up with something similar to Daniel Morin.. with fewer lines in the end vs the solution: numGrades=int(input("how many grades do you have? ")) grades=[] for i in range(0,numGrades,1): grade=float(input('please enter your grade ')) grades.append(grade) print('your grades are: ') for i in range(0,numGrades,1): print(grades[i]) average = sum(grades)/len(grades) print('Here is you average: '+ str(round(average,1)))
@jimsimpson1006
@jimsimpson1006 7 ай бұрын
Got lesson 10 homework, looking forward to moving on! You’ll be pleased to know, Paul, I was shouting my head off at the screen “You need to initialise bucket!” 😂
@jaxonvvv
@jaxonvvv 2 жыл бұрын
folded, folded, folded. Started from lesson 1 again... LEGEND
@ModernDayWanderlust
@ModernDayWanderlust 2 жыл бұрын
I ended up rewatching Tutorials 9 and 2 as a refresher, but yeah, legendary.
@scrappybobbarker5224
@scrappybobbarker5224 2 жыл бұрын
I am legend!!! Thanks for the legendary tutorial series.
@paulmcwhorter
@paulmcwhorter 2 жыл бұрын
No problem 👍
@ziadahmad1472
@ziadahmad1472 2 жыл бұрын
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)
@gerstenpower7398
@gerstenpower7398 2 жыл бұрын
Finally did a homework assignment with the same answer but I did it different. Keep up the good lessons. average=sum(grades)//(numGrades) print('The average of your grades are: ',average,) print('Thats All Folks' )
@paulmcwhorter
@paulmcwhorter 2 жыл бұрын
Great job!
@cannibalseatyourface
@cannibalseatyourface 3 жыл бұрын
Little bit different solution but same results! Great lesson thanks! :)
@paulmcwhorter
@paulmcwhorter 3 жыл бұрын
Thanks! 😃
@tommyfekadu1805
@tommyfekadu1805 3 жыл бұрын
Sir I'd really like to thank you for your effort to spread your knowledge for free GOD bless you. I know someone smart like you will have a very good reason but some of us might be following you full-time and quick thus getting stuck till the next episode... it's exciting as a series movie I can tell you that but if there's anyway you could primer it a bit sooner it would be great humbly asking... Your student Sirak form ETHIOPIA
@426F6F
@426F6F 9 ай бұрын
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!
@426F6F
@426F6F 9 ай бұрын
Here's my code: grades=[] sum=0 highgrade=0 lowgrade=100 n=int(input("Please type in the number of grades to be averaged: ")) for i in range(0,n,1): grade=float(input("Type in a grade: ")) grades.append(grade) if grade>highgrade: highgrade=grade if lowgrade>grade: lowgrade=grade print("The mean average grade of", grades, "is:") for grade in grades: sum+=(grade) mean=sum/n print(f"{mean}/100") print("") print("Highest grade =",highgrade) print("Lowest grade =",lowgrade)
@paulmcwhorter
@paulmcwhorter 9 ай бұрын
LEGEND!
@kriegschwert
@kriegschwert 3 жыл бұрын
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 are fully fuelled!')
@vikram2754
@vikram2754 2 жыл бұрын
Crystal clear explain sir
@paulmcwhorter
@paulmcwhorter 2 жыл бұрын
Thanks and welcome
@arbab8114
@arbab8114 2 жыл бұрын
I did this homework however, instead of using a third for loop, I used the sum() function to sum the grades and then found the average. Works like a charm.
@paulmcwhorter
@paulmcwhorter 2 жыл бұрын
Again, this is like copying and pasting someone elses work. Think through the problem, do it on your own. Else, what will you do when you come to a real problem that has no sum function?
@unlock_don7647
@unlock_don7647 Жыл бұрын
Great content
@ricklawitzky8311
@ricklawitzky8311 2 жыл бұрын
I AM LEGEND Got addicted to your content.
@paulmcwhorter
@paulmcwhorter 2 жыл бұрын
LEGEND!
@visionaryrobotics4065
@visionaryrobotics4065 3 жыл бұрын
unfortunately I folded up like a lawn chair:( I do tried on my own and got stuck. I understand how you did it.
@sabbirahmad8326
@sabbirahmad8326 3 жыл бұрын
Sir, your the best teacher🥰🥰🥰
@paulmcwhorter
@paulmcwhorter 3 жыл бұрын
Wow, thanks
@alexandergiuliani7907
@alexandergiuliani7907 3 жыл бұрын
True, I see how you really want to teach us something. Btw for the homework I used the numpy library.
@burakayan3360
@burakayan3360 3 жыл бұрын
Thank you for the lecture ! Here is my code with little bit extra. I have added some input validation feature in my code to make it more smarter. print("Welcome to the average value calculator program") print("Please enter grades in numerical form. Type 'stop' to terminate program") x= None grades = [] while x != "stop" and "Stop" and "STOP" : x = input() while True: try: x = float(x) grades.append(x) print("The grade ",x," is succesfully added to the data base") break except: print("Please enter grades in numerical form, ") break total= sum(grades) divider = len(grades) average = float( total/ divider) print(" The programm has been terminated ") print("The grades are given at below ") print(grades) print("The average of grades is",average)
@xy3797
@xy3797 2 жыл бұрын
Why this: while x != "stop" and "Stop" and "STOP" , should this be OR instead?
@jstro-hobbytech
@jstro-hobbytech 2 жыл бұрын
i banged my head off a wall doing this and loops in every language ive done before this are easy. i did it this way first and tried a bunch of others. i put sum on the first line before asking for input and for sum=0 reason it didnt work haha i will become a convert paul. thanks
@wendygrant2735
@wendygrant2735 2 жыл бұрын
Found it after thinking through, no coffee needed but a pint of selfbrew beer. I hope you don't mind, at my age(54). Anyway, I'm legend. I haven't asked, are dutch grandma's allowed in here? Joking, mr Paul. I think you are a legend in teaching and my fellow students will agree. numberGrades=int(input('How many grades do you have? ')) grades=[] for k in range(0,numberGrades,1): grade=float(input('Give me grade ')) grades.append(grade) sum=0 for k in range(0,numberGrades,1): sum = sum + grades[k]; average=(sum/numberGrades) print('You have an average of' ,average) print('Your grades are:') for k in range(0,numberGrades,1): print(grades[k])
@alexgordon9795
@alexgordon9795 2 жыл бұрын
I don't know if you read comments on older videos, I hope you do, I did the homework a different way and would love your feedback! I think it's much simpler, so I hope I'm not missing out on learning some important things by simplifying the concept. If you're interested this is mine: gradesTotal=int(input('How many grades do you have: ')) grades=[] for i in range(0,gradesTotal,1): grade=float(input('Please type in your grade here: ')) grades.append(grade) print('Your grade is: ', grade) total=sum(grades) average=total/gradesTotal print('Your grade average is: ', average) print('your grades are: ', grades) print('Thanks for playing!')
@benthompson6118
@benthompson6118 Жыл бұрын
I did it the same as you
@criptosauro4587
@criptosauro4587 Жыл бұрын
I did it same way. he said something about the for loop so I tried. but since I couldn't, I made it the simple way hahah
@criptosauro4587
@criptosauro4587 Жыл бұрын
amount = int(input("How many grades do you have? ")) grades = [] for i in range(0,amount,1): grade = float(input("Give me your grade ")) grades.append(grade) average = sum(grades) / amount print("Your average is: ", average) for i in range (0,amount,1): print(grades[i])
@1nabru259
@1nabru259 9 ай бұрын
does the sum add together every number in grades?
@pauivorra1819
@pauivorra1819 3 жыл бұрын
Love your explanations about how we are jet fighters and our fuel is coffee
@markhouston2537
@markhouston2537 2 жыл бұрын
More doers, less watchers :) Champion!!
@igortomic1525
@igortomic1525 3 жыл бұрын
Not us.. You are the legend. By the way, did your homework assignment. Not the same solution but it is the same result.
@martinc9215
@martinc9215 Жыл бұрын
Legend!
@Sauric121
@Sauric121 3 жыл бұрын
Hi Paul! I was able to do this in two loops by just typing the lines average=(sum(grades)/numGrades) and print('Here is the GPA: ', average) Would coding it like this cause problems, or were there simply multiple solutions to this homework?
@Nick-xz1qq
@Nick-xz1qq 3 жыл бұрын
I am Legend. Thanks you again from Georgia
@AZStickman
@AZStickman 8 ай бұрын
I am legend... :-) Thanks for your great tutorials Paul! (Full disclosure; I obtained the right result but did not do it using the code you demonstrated)
@paulmcwhorter
@paulmcwhorter 8 ай бұрын
LEGEND!
@Bianchi77
@Bianchi77 3 жыл бұрын
Cool video , vote up :)
@jonathanlanders9406
@jonathanlanders9406 Жыл бұрын
Almost had it. I had one line of code that was messing me up. Great homework!
@rafabaez
@rafabaez 2 жыл бұрын
I did it a little different, but works very well, even though grades are from, like 50 (lowest) & 150 (highest). # Lesson 10: More on for loops # Homework: In the same last practice, find also the highest grade as well as the lowest one numGrades=int(input('Please enter the number of grades: ')) myGrades=[] mySum=0.0 myAvg=0.0 myLow=0.0 myHigh=0.0 # Reads grades for i in range(0,numGrades,1): grade=float(input('Plese enter grade: ')) myGrades.append(grade) # Print all grades for i in range(0,numGrades,1): print('Grade ',i+1,' is ',myGrades[i]) # Average grades for i in range(0,numGrades,1): mySum=(mySum+myGrades[i]) # Print Avg Grade myAvg=mySum/numGrades print('average ',myAvg) # Find lowest grade & print it myLow=myGrades[0] for i in range(1,numGrades,1): if myLow > myGrades[i]: myLow=myGrades[i] print('Lowest Grade is',myLow) # Find highest grade & print it myHigh=myGrades[0] for i in range(1,numGrades,1): if myHigh < myGrades[i]: myHigh=myGrades[i] print('The highest grade is ',myHigh)
@chrisingram7277
@chrisingram7277 3 жыл бұрын
I am legend.... but mainly best wishes for the move, hope to hear from you next week:)
@paulmcwhorter
@paulmcwhorter 3 жыл бұрын
Thanks, you too!
@ivan-dk3sl
@ivan-dk3sl 4 ай бұрын
I give you a thumbs up👍👍👍
@frankfaubert1927
@frankfaubert1927 5 ай бұрын
I'm one of the lawn chairs 😂. Populating the array with a for loop was easy as was the averaging. The part I couldn't crack was getting the info back out using a for loop. I can't figure out how to call the indexes in a series without listing each of the indexes by name.
@johnhansen4794
@johnhansen4794 3 жыл бұрын
LOL: was going to do hi lo on last week's HW. Is it ok if I ask for an ID# to associate with the grade.
@tonytungate4540
@tonytungate4540 3 жыл бұрын
I am Legend! Great Job..Thank you
@paulmcwhorter
@paulmcwhorter 3 жыл бұрын
Welcome 👍
@advancedperformance9721
@advancedperformance9721 3 жыл бұрын
thank you sir
@paulmcwhorter
@paulmcwhorter 3 жыл бұрын
Most welcome
@thebrector3823
@thebrector3823 2 жыл бұрын
I AM LEGEND, I actually almost folded up like a lawn chair but I realized I did a stupid mistake!!! little different code but : Ng=int(input('Please enter the number of grades you have: ')) Gs=[ ] GAC=0 for j in range(0,Ng,1): G=float(input('Please enter Your grade: ')) Gs.append(G) GAC=GAC+G print(GAC) print('Your avergage grade is: ', GAC/Ng) print('And Your grades are:') for j in range(0,Ng,1): print(Gs[j]) print('Done!, Thank you!!') The stupid mistake was putting the GAC=0 in the for loop, so it would add the 1grade and then make it 0....... thank u a lot sir!!
@maku5289
@maku5289 Жыл бұрын
Another (3rd) day in-a-row 💥☕ Was able to do this homework by skipping the range and calling the array directly (for the average and printing) with: 'for i in grades:' sum+=i (where grade=[ ] and sum = 0). Wonder if that was ok? Same thing for printing grades: 'for i in Grades:' print (i)
@bola5671
@bola5671 2 ай бұрын
I copied everything including bucket=[] but it didn't work I then changed bucket=0, and then it worked. I wonder if it's because of an update in python because bucket isn't a list but initializing to zero before running it. Anyone having issues could try this!!! And send some love to Paul cause this man is doing God's work.
@railcat7083
@railcat7083 3 жыл бұрын
Legendary... boom!
@randallstephens3151
@randallstephens3151 3 жыл бұрын
I was a legend, coming up with the same solution more or less. However, I used the name sum where you used bucket. Later, I found that sum is actually a library function, so I must have overrode the function?! Still worked, but probably bad form.
@steveholt8991
@steveholt8991 22 күн бұрын
Yes I did it. When printing out the array or averaging, is it not easier to say "for grade in grades:" rather than "range" ?
@erichzakopal9778
@erichzakopal9778 2 жыл бұрын
I'm legend :-) , @Paul thx really nice lessons
@paulmcwhorter
@paulmcwhorter 2 жыл бұрын
LEGEND!
@markloyd8616
@markloyd8616 3 жыл бұрын
I was able to do the homework, but I did the summing a little differently. I did not use "range". sumGrades=0 for i in myGrades: sumGrades=sumGrades+i In practice, would this be good, bad or indifferent?
@arghyadipchowdhury9268
@arghyadipchowdhury9268 2 жыл бұрын
legend never dies
@dzeykop
@dzeykop Жыл бұрын
Thank you for another great lesson, Sir! Not wasted time (#NWT) for me! 👍
@paulmcwhorter
@paulmcwhorter Жыл бұрын
My pleasure!
@blasterTC
@blasterTC 3 жыл бұрын
Are we allowed to user max() and min() methods for homework or must we find a way via for loops?
@paulmcwhorter
@paulmcwhorter 3 жыл бұрын
Better to do it with a for loop so you are doing the thinking and learning. Library functions can be an un needed crutch.
@jamesdubben3687
@jamesdubben3687 3 жыл бұрын
Is variable type naming delimitation oldschool? That is, put in an extra character in the variable name so you know what you intended it to contain. Examples: fSum - float Sum iNum - integer Num sList - string List
@noweare1
@noweare1 2 жыл бұрын
That helps. It has been around a long time and many programmers use that formatting of variables.
@ben_shoots_
@ben_shoots_ Жыл бұрын
I am legend! Although I used sum instead of additional for loops!
@jstro-hobbytech
@jstro-hobbytech 2 жыл бұрын
couldnt go to bed without doing it. bubble sort logic but without moving the elements around. first time i thought of a buble sort in over 20 years. i crushed it. took a few minutes before bed.
@user-oi8zi2zh4q
@user-oi8zi2zh4q Жыл бұрын
Hey Paul, Thanks for lessons I will hit the Patron account. I was able to do this with only 2 for loops and I searched help section and found the sum() function so I just summed the grades and divided by numGrades. It worked but I am worried maybe that is a bad habit to start?? Thanks again
@josegermanmolina3544
@josegermanmolina3544 2 жыл бұрын
I m legend! (Althoug Had to help me a little with another video.)
@rafabaez
@rafabaez 2 жыл бұрын
Did it, but it took me like half an hour... That for loop is very different from other languages. It's ok. Thank you Sir!
@farshadrozati5334
@farshadrozati5334 2 жыл бұрын
Hi Paul, I did mine slightly different. You mentioned that you shouldn't be taking the average inside of the for loop but I did using sum() and division and still managed to get it to work. Can you look at my code and let me know why it's best that I avoid this practice or if it is fine? Thank you: numGrades=int(input('How many grades do you have? ')) Grades=[] for i in range(0,numGrades,1): grade=float(input('Please Enter Your Grade: ')) Grades.append(grade) for i in range(0,numGrades,1): print(Grades[i]) for i in range(0,numGrades,1): totalGrade=sum(Grades) avgGrade=totalGrade/numGrades print('Your Grade Average is:', avgGrade)
@dvstarzzots
@dvstarzzots Жыл бұрын
I AM A LEGEND! I come here for the homework
@paulmcwhorter
@paulmcwhorter Жыл бұрын
LEGEND!
@seditiousmonkeyart
@seditiousmonkeyart 3 жыл бұрын
\(".")/ Woohoo!!! nailed it!!! although I did look up the sum() function instead of running a 'for loop'. I figured Python would have a sum() function like every other language. owever, I did the same rooky mistake first time round and forgot to declare 'sumGrades'. Took me a moment or two to think it through. Your instruction is most excellent and I have learned.
@Mouse_007
@Mouse_007 3 жыл бұрын
nice, I would have used the sum() function too if I'd known about it !
@jeff_wild
@jeff_wild 28 күн бұрын
Double chest pump. It's interesting that the index in the for loop that populates the array is superfluous.
@Bretonjar1
@Bretonjar1 2 жыл бұрын
So initially I summed the list and then divided that by numGrades before watching this video, however I tried your method and in the line bucket = bucket + grades[1] I am getting an error "TypeError: can only concatenate list (not "float") to list", can anyone help me out, seems that is something to with only being able to add certain variables together but I have tried forcing variables to certain types and nothing is working. However, my code is exactly the same. Maybe its a version thing, I am running Python 3.9.7 on windows.
@jbradley4201984
@jbradley4201984 Жыл бұрын
This is the way I did it. Would it be correct also? listed_grades = [] num_grades = int(input("How many grades do you have? ")) for grades in range (num_grades): grades = int(input("What are your grades? ")) listed_grades.append(grades) print("Your average is") print(sum(listed_grades)/ num_grades)
Survive 100 Days In Nuclear Bunker, Win $500,000
32:21
MrBeast
Рет қаралды 101 МЛН
Slow motion boy #shorts by Tsuriki Show
00:14
Tsuriki Show
Рет қаралды 10 МЛН
A little girl was shy at her first ballet lesson #shorts
00:35
Fabiosa Animated
Рет қаралды 16 МЛН
CHOCKY MILK.. 🤣 #shorts
00:20
Savage Vlogs
Рет қаралды 13 МЛН
Why The Windows Phone Failed
24:08
Apple Explained
Рет қаралды 234 М.
Python Tutorial 6: How to Use If Statements and Conditionals in Python
29:30
Python Tutorial 19: Python Classes and Methods Homework Examples
57:57
C vs C++ vs C#
2:26
conaticus
Рет қаралды 1,8 МЛН
The size of your variables matters.
11:03
Core Dumped
Рет қаралды 106 М.
Python Tutorial 9: Understanding For Loops in Python
36:39
Paul McWhorter
Рет қаралды 42 М.
Мой новый мега монитор!🤯
1:00
Корнеич
Рет қаралды 658 М.
Tag him😳💕 #miniphone #iphone #samsung #smartphone #fy
0:11
Pockify™
Рет қаралды 4,4 МЛН
Samsung laughing on iPhone #techbyakram
0:12
Tech by Akram
Рет қаралды 7 МЛН
Look, this is the 97th generation of the phone?
0:13
Edcers
Рет қаралды 8 МЛН