Python Tutorial 11: Finding Maximum and Minimum Numbers in a List in Python

Поделиться
HTML-код
  • Опубликовано: 1 ноя 2024
  • НаукаНаука

Комментарии • 293

  • @mecatronicsforeveryone9565
    @mecatronicsforeveryone9565 3 года назад +23

    you literally changed my life. I just can't get enough of your classes. I started Arduino with you. and now python. I wish you the best, wherever you are and whatever you do.

  • @neilausten9404
    @neilausten9404 3 года назад +29

    Your teaching style makes it almost seem as though you are here, in my room, in person. Makes it easy to learn for folk of any age.(spoken by a 76 year old). Can I do a one off donation?

    • @paulmcwhorter
      @paulmcwhorter  3 года назад +6

      Thank you for the kind words. Donations can be made at my patron account, with a link above in the video description, or can be sent via paypal to paul.mcwhorter@gmail.com Thanks!

  • @petefontana1958
    @petefontana1958 2 года назад +3

    I am a 75 year old legend. My solution was to stored the first grade in the array as minimum grade in one for loop, and as the maximum grade for the other for loop.This way I can use this same function in any program to determine high and low.
    I started with your Arduino tutorial 18 months ago. You have kept my mind from turning into mush. Keep up the good work and God Bless

    • @426F6F
      @426F6F Год назад

      That's a smart solution! I like that it uses the first input grade as the reference grade.

  • @HonestDino
    @HonestDino 3 месяца назад +1

    Great teacher, great character, great mind! God bless you!

  • @sabbirahmad8326
    @sabbirahmad8326 3 года назад +9

    sir, your lecture about python is better than any other lecture series even the paid course............

    • @sunilkulkarni4426
      @sunilkulkarni4426 3 года назад +1

      True indeed

    • @426F6F
      @426F6F Год назад

      I agree. Paul is not only a great teacher, but a fantastic engineer. He conveys complex information in such a simple, easy-to-grasp way for everyone. That's how you know he's so knowledgeable!

  • @thisismyworkshop6654
    @thisismyworkshop6654 3 года назад +2

    Hey, Paul!
    The way I did the homework was -
    # max grade
    max=grades[0]
    for i in grades:
    if i > max:
    max=i
    print('Max grade is: ', max)
    #min grade
    min=grades[0]
    for i in grades:
    if i < min:
    min=i
    print('Min grade is: ', min)
    This way we are not stuck to 0-100 system, we might as well give negative grades. Is there a school somewhere in the world where teachers give negative grades, though? :)
    I love your tutorials and it's a pity, these tutorials are not used in high school programs all around the world.. Especially in this C19 era..
    I can't wait to see the next ones.
    Wish you all the best!

  • @vaughntaylor2855
    @vaughntaylor2855 3 года назад +4

    I initially set lowGrade and highGrade to the first value of the grades list which also worked. Thank you Paul!!

  • @TyroneJester
    @TyroneJester 3 года назад +1

    i am legend. Omg i was having so much trouble understanding loops but theses last couple of homeworks helped alot. i rewatched them over and over again untill it stuck. keep up the good work. you have a fan here in Ireland, great teaching method

  • @iansesat6643
    @iansesat6643 3 года назад +2

    To the best online teacher, thank you for the content. You make us see the fun in doing engineering. It isn't always about the hard stuff, we can also do a lot of cool stuff

  • @426F6F
    @426F6F Год назад

    I ended up calculating the high grade, low grade, sum, and appending each grade to grades, as the user types them in - all within one for loop! Thanks Paul!

  • @LiamAllbright
    @LiamAllbright 11 месяцев назад

    This course is legendary. you literally changed my life, and in some way, encouraged me to learn blender! Cant wait for more. 👍 Love these lessons!

  • @charlielowell4077
    @charlielowell4077 2 года назад

    I AM LEGEND! I beat the lesson #10 homework with that folded up Walmart lawn chair like it was a cheap Walmart rug. It didn't take much tinkering. I guessed that there was a means of showing the min & max values of "something" so I experimented and got it right pretty quickly. Thanks again for the retiree brain food! By the way, I have done the last two homeworks with only two "for's"???? It works.

  • @opalprestonshirley1700
    @opalprestonshirley1700 3 года назад +1

    Finished the homework, made this old man's brain work overtime, but she'll sort with best of them. This just gets better and better. See you next week.

  • @johnmontesi383
    @johnmontesi383 Год назад

    Thank you for putting out these tutorials. I have been able to complete each of the homework assignments although I tended to complete them differently. Rather than keep creating loop statements I combined several operations into less loops. My thought is that the less coding you have to do... the less of a chance for error. Maybe this goes back to my programming years ago in languages that would seem foreign today. But your lessons definitely help with my understanding of the syntax of Python.

  • @codecage9333
    @codecage9333 3 года назад +3

    Two if statements for last week's homework! I'll go ahead and post my "I am legend!"

  • @nyrootu9954
    @nyrootu9954 3 года назад

    YOU ARE ONE OF MY MENTORS, A MAN OF GOD AND MAN OF KNOWLEGE. I SEE MY OLD SELF. GOD BLESS YOU SIR

  • @jabber2824
    @jabber2824 4 месяца назад

    I am legend. You could also initialize the high and low value with the first number in the array. Then you wouldn’t have to know the scale of what you are going through. HighestGrade = grades[0]. Great lesson as usual! Thank you !

  • @saptangshumanna9919
    @saptangshumanna9919 2 года назад +5

    In my solution instead of setting lowgrade and highgrade as 100 and 0 respectively, I defined both of them to be equal to grades[0]. I did it in case the user has grades more than 100. And this would help to find the min and max for any value of the array.

  • @go-ek7sg
    @go-ek7sg 6 месяцев назад

    I am Legend! I folded up like a lawn chair on the last homework but got this one.
    Thank you so much for these lessons.

  • @hmccall3
    @hmccall3 2 года назад +1

    Thanks for another great lesson Paul! I made sure I could do it by using for loops, then I re-wrote the code and cheated by using the min(array) and max(array) functions. I think it's important to learn all the ways to skin a cat! LOL

  • @bryankohn9660
    @bryankohn9660 3 года назад

    I am legend. Got this via two methods. A for loop that steps thru and compares each grade, and also used a Python list methods .min and .max. This revealed that there are many many many list methods in Python.

  • @86Carrera911
    @86Carrera911 3 года назад

    I am LEGEND!
    I did the low and high grade checking in the same loop, and initialized both of the values to grades[0]. As the size of the data set increases, your execution time will increase at a lower rate.

  • @leandersachin9666
    @leandersachin9666 3 года назад +2

    Love to see you teaching us C someday. Shout out for the Best teacher on youtube.

  • @chrisb7250
    @chrisb7250 Год назад

    I wrote a python program with a conditional statement that turns a pump "On" when the depth in a tank reaches a specific "Minimum depth" and shuts the pump off when it reaches a specified "Maximum depth". I am excited to put this into practice with my arduino.

  • @alfredcalleja450
    @alfredcalleja450 Год назад

    Hi Paul, thanks for another great tutorial. I worked it out on my own (with the help from your hints) but I had a lot of pain with my using == instead of =. Thanks for pressing home the value of doing it myself instead of just copying your code: I banged my head against the wall quite a bit. 🥳

  • @professorxavier9692
    @professorxavier9692 2 года назад

    I folded up like a cheap Walmart lawn chair but spent 3 hours experimenting with all of the things you can do with loops and integers and had so much fun haha! I feel like struggling, even if you eventually don't find the solution is important for sure.

  • @charlielowell4077
    @charlielowell4077 2 года назад

    After thinking about it, I realized I used Python's built in functions for min & max. While that worked and worked very well I saw that, since other programming languages probably don't have the same built in's that Python 3 has, I needed to redo my homework. That said, I owe you an apology as I did both you and myself a disservice. I managed to redo the min & max homework "old school" style, but had a lot of difficulty. I finally got it to where it works but i still don't think I got it done the way I was supposed to. I'm going to go through #11 again so I can see where i can improve my code. I need to do the same for lesson #12, as the sort("list") function is also probably not the best way to do it. Certainly the easiest, but not the best. Thanks again, sir.

    • @paulmcwhorter
      @paulmcwhorter  2 года назад +1

      Yes, the point of the lesson is to get you to think through the complicated problem. Map out a strategy, and then code it. Using the built in functions you really dont learn anything and really dont build brain power.

  • @chrisb7250
    @chrisb7250 Год назад

    I found a couple of different methods of completing this assignment. The first way was to use the max and min functions in python. The second way was using a for loop, and first assuming min is equal to grades array position [0]. Then as it would iterate through grades it would check each position, and if it was less than min, that would become the new min.
    min = grades[0]
    for i in grades:
    if (i < min):
    min = i
    print('Min:', min)

  • @cbrombaugh
    @cbrombaugh 3 года назад

    I AM LEGEND AGAIN! Small addition to previous homework. Thanks, Paul!

  • @bertmouthaan
    @bertmouthaan 2 года назад

    I tried and succeeded ... very nice lessons after the Arduino series ... thanx Paul!

  • @irete267
    @irete267 Год назад

    I am a legend. I used the very first element in the list as both the low grade and the high grade. Seems it works either ways:) Been enjoying your lessons btw keep up the good work sir.

  • @jg1950mc
    @jg1950mc 3 года назад

    Great teaching! my code with one for loop for all calculations and one for loop for printing
    '''
    average the grades and print average and all grades given
    find the highest and lowest grades entered
    '''
    grades = []
    total = 0
    high = 0
    low = 100
    num1 = int(input('How many grades will you enter? '))
    for grade in range(num1):
    grade = int(input('Enter a grade: '))
    if grade > high: high = grade
    if grade < low: low = grade
    grades.append(grade)
    total = total + grade
    print('you entered: ', end = ' ')
    for g in range(0, num1, 1):
    print(grades[g],end = ', ')
    print('The average grade is:', total / num1)
    print('The highest grade is', high, 'and the lowest grade is', low)

  • @MrElFRanz
    @MrElFRanz 3 года назад +1

    Hello Paul;
    Today I finished the homework of this lesson, and I did not use the sort function. It took me many hours. I am 78 years old, and your homework keep my brain from rusting.

  • @ecassar1975
    @ecassar1975 3 года назад

    I am legend. My solution was similar to yours but I placed both if statements in a single for loop. Many thanks Mr. McWhorter

  • @SimpleHumanInNY
    @SimpleHumanInNY 2 года назад +1

    I have learnt something new today, thank you for the video.
    I must say I cheated a bit with the solution, I apologize to Mr. McWhorter and the community.
    I used the sort function on the array and then just pulled and displayed the first element (at index 0) and the last element (at index -1) in the list of grades.

  • @lananhnguyen2925
    @lananhnguyen2925 Год назад

    Thank you so much!! I learn a lot and I very appreciate all your great videos

  • @sailingskismo
    @sailingskismo 9 месяцев назад

    Well, I did some interweb research and found two python keywords (min & max) so I just used two lines to determine the lowest and highest values
    results.append(result)
    maxGrade=max(results)
    minGrade=min(results)
    print('and your lowest grade was', minGrade , 'while your highest grade was' , maxGrade)
    Having tested it, it works ok.

  • @FernandoMartinez-kw9kj
    @FernandoMartinez-kw9kj 2 года назад +3

    Figured it out :) I miss the Arduino IDE where all the variables are declared from the start and you know what you’re working with. I hope i will recognize the benefits of python later on, for now it gives me headaches haha

  • @pauivorra1819
    @pauivorra1819 3 года назад +2

    As always, great lesson Sir

  • @JackVersey
    @JackVersey 6 месяцев назад

    Going to declare myself super legend here. Only used 2 for loops, 19lines of code in total. I particularly like the simplicity of lines 7-14 which ensures the first entry is always both the highest and lowest grade and takes care of it from then on (also any real value of grades can be used here...
    gradesnum = int(input('How many grades are there? '))
    grades, total, highest, lowest = [], 0, 0, 0
    for i in range(0, gradesnum):
    grade = float(input('what is grade number ' + str(i + 1) + '? '))
    grades.append(grade)
    total = total + grade
    if(i == 0):
    highest = grade
    lowest = grade
    else:
    if(grade > highest):
    highest = grade
    if(grade < lowest):
    lowest = grade
    print('The grades are as follows:')
    for i in range(0, gradesnum):
    print('Grade' + str(i + 1) + ':', grades[i])
    print('The average of the grade is', total/gradesnum)
    print('The highest grade was', highest, 'and the lowest grade was', lowest)

  • @hughpatterson1480
    @hughpatterson1480 2 года назад

    Great lesson Paul! While I was able to create the homework problem, I had a problem with the average adding up the grades entered rather than averaging them. It ended up being a rookie mistake. However, you learn more from making mistakes that getting things right the first time!

  • @geoffwade8144
    @geoffwade8144 2 года назад

    I am legend, I suppose.... I only used 1 for loop and did all of the calculations in the same loop. Much different from Pauls' solution, kind of missed the point of where Paul is leading us I think, but I get it now.

  • @MuhammadHamza-ki3ze
    @MuhammadHamza-ki3ze 3 года назад +1

    I stored first element of grades as minimum grade in one loop, and maximum grade for the other loop and it works perfectly
    I am a Legend

  • @TheSudouser
    @TheSudouser 2 года назад

    Got it! Struggled but got it! Thanks TTB!

  • @nielsroetert
    @nielsroetert 3 года назад +1

    Have you looked at using formatted string literals at all, they were introduced in Python 3.6 and make your code look so much nicer.
    From my homework: print(f'Your average grade is {average}, your lowest grade is {low_grade} and your highest grade is {high_grade}')

  • @boydrogers7227
    @boydrogers7227 3 года назад +3

    Done by consolidating functions into two "for" loops, hence I AM LEGEND (all caps).

  • @Azekanawesom
    @Azekanawesom 5 месяцев назад

    hey paul,love your teaching and ur efforts. Absolutely phenomenal.Heres my code(slightly different than urs):
    n=int(input('Enter the no. of grades:'))
    grades=[]
    sum=0
    for i in range(0,n,1):
    grade=int(input('Enter your grade:'))
    grades.append(grade)
    sum=sum+grade
    for j in range(0,n-1,1):
    if(grades[j]grades[j+1]):
    max= grades[j]
    min=grades[j+1]
    avg=sum/n
    print('ur grades are:')
    print(grades)
    print('ur average grade is:',avg)
    print('ur maximum grade is:',max)
    print('ur minimum grade is:',min)

  • @Hyrkan24
    @Hyrkan24 2 года назад

    I AM LEGEND! took me an hour and a half to solve it but I resisted the temptation to just google the answer

    • @Hyrkan24
      @Hyrkan24 2 года назад

      I did it a bit differently and a more roundabout way hahaha

  • @danielduplessis7221
    @danielduplessis7221 3 года назад

    I Am Legend!
    Thank You Mr. Paul For Your Excellent Tutorials!

  • @ICit123
    @ICit123 3 года назад +1

    I kept the original program and added this python line at the end of the program: print("Maximum grade is :", max(grades), "
    Minimum grade is :", min(grades)) It works with no FOR LOOP necessary.

    • @paulmcwhorter
      @paulmcwhorter  3 года назад

      But the object of the lesson is to think through a complex problem analytically, and then design a solution and code it. Simply using someone else's canned function, you do not learn how to think through the problem. These min, max, average and sort problems are classic coding problems, and people need to know how to solve them.

  • @hassanniaz7583
    @hassanniaz7583 3 года назад +1

    Here's how I did it:
    x=[]
    question=int(input('How many grades do you want to enter: '))
    questions=question+1
    for ques in range(1,questions,1):
    y=float(input('Enter your Grade '))
    x.append(y)
    num=1
    for grades in x:
    print('Your grade#',num,'is: ',grades)
    num=num+1
    sum=0
    max=x[0]
    min=x[0]
    for grades in x:
    sum=sum+grades
    if(max=grades):
    min=grades
    print('The average of given grades is =',sum/question)
    print('Your maximum grade is:',max)
    print('Your minimum grade is:',min)

  • @dzeykop
    @dzeykop Год назад +1

    Thank you for another great lesson, Sir! Your lessons are not wasted time (#NWT) ! 👍

  • @ShinesMonkey1
    @ShinesMonkey1 3 года назад +1

    Did not watch live, but I was Legend!

  • @praneethreddy6947
    @praneethreddy6947 3 года назад +1

    SIR LOVE FROM INDIA (U ARE soo dam great!!!)

  • @mannatkaur1146
    @mannatkaur1146 3 года назад +2

    Hi Paul, I wanted to ask something.
    You said that we have to use a for loop in order to sort the numbers in the list. I did it by using the 'sorted()' function command. Is that right or it would be better to find it using a for loop?

    • @paulmcwhorter
      @paulmcwhorter  3 года назад

      What do you learn by using a canned function . . . noting. You have not learned to analyze a hard problem and then develop and implement an algorithm to solve. That is what you need to learn how to do, as that is what people will pay for.

    • @mannatkaur1146
      @mannatkaur1146 3 года назад

      @@paulmcwhorter Yeah. Thank you!

  • @lemonlover5011
    @lemonlover5011 Год назад

    Love your lessons

  • @colefisch931
    @colefisch931 Год назад

    I did lowGrade=grades[0] to make the first grade in the list default as the low and then check against it. that also worked for me.

    • @lananhnguyen2925
      @lananhnguyen2925 Год назад +1

      Hi cole, yes I also do the same. I actually think this could be more accurate. For example, if we are not talking about grades but an array of random numbers, if all the inputs are more than 100, the it will show 100 as the minimum which is incorrect. But doing your way, no matter how large the number is, it always turns out the correct minimum.

  • @blasterTC
    @blasterTC 3 года назад +3

    My solution was to first start with biggest grade and then, when searching for smallest, make the initial variable same as the biggest so i know it cannot get lower than low.

  • @danielbanks7500
    @danielbanks7500 3 года назад

    I am legend! Sadly I missed this live today!

  • @pasteltiara
    @pasteltiara 3 года назад

    Really having fun, rising the rank of I am Legend.

  • @criptosauro4587
    @criptosauro4587 Год назад

    I did the same solution.
    another way I thought was to set :
    high_grade = grades[0]
    low_grade = grades[0]
    but this way have to write after the first for loop cause at the beginning grades[0] is empty
    here is the rest:
    # Ask the amount of grades
    amount = int(input("How many grades do you have? "))
    grades = []
    total = 0
    high_grade = 0
    low_grade = 100
    # write all grades in the grades[]
    for i in range(0,amount,1):
    grade = float(input("Please share your grade "))
    grades.append(grade)
    # Calculate the average (2 different ways)
    average = sum(grades) / amount
    for i in range(0, amount, 1):
    total = total + grades[i]
    average_2 = total/ amount
    # MAYOR
    for i in range(0, amount, 1):
    if grades[i]>= high_grade:
    high_grade=grades[i]
    # Menor
    for i in range(0, amount, 1):
    if grades[i]

  • @Al-dp1pe
    @Al-dp1pe 3 года назад

    Paul the background screen saver - cool ! Can you provide a link to where I can down load it

  • @MrElFRanz
    @MrElFRanz 3 года назад +2

    The sort, max and min Python functions make things easier.

    • @paulmcwhorter
      @paulmcwhorter  3 года назад +1

      The goal is not the easy solution, the goal is to learn to think through a problem and implement a solution. Using canned funcitons, what have you really learned?

  • @michelspedding2032
    @michelspedding2032 Год назад

    I'm a 65 year Legend, thanks to you.

  • @jeff_wild
    @jeff_wild 3 месяца назад

    I am legend. I tracked high and low scores while adding to the array, so no new for statements needed. Initially set high to zero and low to 100.1

  • @leprechaun947
    @leprechaun947 2 года назад

    Thank you for these excellent lessons! Here's my solution to exercise 9/10:
    # Grades program by leprechaun947
    # Guided by Paul Mc Whorter and fuelled by strong coffee
    # Define array to hold grades
    grades = []
    # collect grades and populate the array
    numGrades = int(input("Please enter the number of grades: "))
    for i in range(numGrades):
    grade = int(input("Please enter grade: "))
    grades.append(grade)
    print("
    Your grades are:")
    # Print out list of grades
    for grade in grades:
    print(grade)
    # Calculate average grade
    sum = 0
    for grade in grades:
    sum += grade
    average = sum/numGrades
    print("The average grade is: ", average)
    # Find the highest grade.
    high = grades[0]
    for grade in grades:
    if grade > high:
    high = grade
    print("The highest grade is", high)
    # Find the lowest grade.
    low = grades[0]
    for grade in grades:
    if grade < low:
    low = grade
    print("The lowest grade is", low)
    print("
    Done - thank you
    ")

  • @narlyb1500
    @narlyb1500 Год назад

    I used IF statements in the first for loop:
    """
    1) ask the user for how many grades they have.
    2) input those into an array.
    3) average the grades
    4) print out the average
    5) print out all the grades
    6) print out the highest and lowest grades
    ------------------------------------------------------------------------------
    """
    grades=[]
    number_grades=int(input('How many grades do you have? :'))
    high_number=float(0)
    low_number=float(0)
    for i in range(number_grades):
    grade=float(input(f'What is grade #{i+1} :'))
    if high_number==0:
    high_number=grade
    low_number=grade
    if grade>high_number:
    high_number=grade
    if grade

  • @jimsimpson1006
    @jimsimpson1006 10 месяцев назад

    I am legend. Well, getting there bit by bit…
    Again, Paul, you’ll be glad to know I was shouting at you to initialise, but as you’re in Texas and I’m in Ireland you probably didn’t hear me.

  • @mannatkaur1146
    @mannatkaur1146 3 года назад +2

    Can we also use the min() and max() function instead of this for loop?

    • @paulmcwhorter
      @paulmcwhorter  3 года назад +2

      No, because you do not learn how to think and problem solve with that.

    • @littricks3631
      @littricks3631 3 года назад +1

      I wanted to use them bro,cause I thought there's no restriction on what the user can type(here he's typing marks so it has to be any number within the range 1-100)...but say the guy typed 32767,that value won't be read by this program and we would require the functions you mentioned!
      You're good to use it if you thought like I did

  • @bhuvansk6770
    @bhuvansk6770 4 месяца назад

    ahh sir i still initialized both max= 0 and min = 0 and got the same output ? so is tat wrong or right i just wanted to know , program worked the same but i got the output correct itself like the lowgrade and highgrade were shown correct after initializing them both as 0
    x = int(input('How many grade do you need : '))
    z = []
    min= 0
    max =0
    s= 0
    max = 0
    for i in range(0,x,1):
    y = int(input('Enter the grade : '))
    z.append(y)
    s = s+z[i]
    min = z[0]
    avg = s/x
    print('Your ',x,' grades are : ')
    for i in range(0,x,1):
    print(z[i])
    print('Average of your grades = ',avg)
    for i in range(0,x,1):
    if(z[i] < min):
    min = z[i]
    if(z[i]>max):
    max = z[i]
    print('Your lowest grade = ',min)
    print('Your highest grade = ',max)

  • @yveslagace8212
    @yveslagace8212 2 года назад

    Paul, I am LEGEND !

  • @whimsicalkins5585
    @whimsicalkins5585 2 года назад

    I gave my level best. But I was not able to write the code myself. Thanks for teaching us

  • @lakshmadaan8871
    @lakshmadaan8871 2 года назад +1

    sir I actually used the max() and min() functions in my program. Is that fine with you?....It worked like a charm...

    • @paulmcwhorter
      @paulmcwhorter  2 года назад +1

      Well, it is a little like getting someone else to write your code for you. You need to think through this and do it on your own. What will you do when you get to a harder problem where there is not a canned library?

    • @lakshmadaan8871
      @lakshmadaan8871 2 года назад +1

      @@paulmcwhorter sure sir I will think this through from next time

    • @lakshmadaan8871
      @lakshmadaan8871 2 года назад +1

      Thanks a lot for the advice sir!!.... I was able to do the sorting one myself without functions🎉🎉🎉🎉🎉

  • @drorlivneh4499
    @drorlivneh4499 2 года назад

    thank you , you are legend!

  • @thekanwalchaudhari5225
    @thekanwalchaudhari5225 Год назад

    Sir to find maximum we can use the function max().
    And for minimum we can use min().
    So in this case it will be max(grades) and min(grades)

    • @paulmcwhorter
      @paulmcwhorter  Год назад

      The whole point of the lesson was for you to think through the problem, and solve a difficult challenge by careful analysis and critical thinking, not just use a canned library, so no, dont use the functions figure out the logic and write the code.

  • @ModernDayWanderlust
    @ModernDayWanderlust 2 года назад

    Took me a bit of playing around before I was happy with this one, I was trying to get too cute with it and do everything in a single loop. I defined both highGrade and lowGrade to gradeValues[0] initially so that any funky grades (over 100, etc) would still read correctly.

  • @chernoblyat1901
    @chernoblyat1901 3 года назад +1

    I've done some deep research through Google on how to find smallest and highest numbers in arrays.
    The easiest way I found was to use the command "min" for smallest number and "max" for highest number on my own!
    Does this count as individual hard work or did I fold it up like a cheap Walmart lawn chair?

    • @paulmcwhorter
      @paulmcwhorter  3 года назад +1

      Really you want to think through it. It is a classic problem and will train your brain to think through such things.

    • @chernoblyat1901
      @chernoblyat1901 3 года назад

      @@paulmcwhorter agreed, most programing tutorials on RUclips doesn't bother to giver the viewers homework which makes it feel unimportant to the viewers

  • @wendygrant2735
    @wendygrant2735 2 года назад

    Jetfuel, not soda-pops, not coca-cola's, not mountain dews. In my country we have an ad that says 'Red Bull gives you wings'.
    Mr McWhorter maybe drinking this is the solution to fly the jet.

    • @paulmcwhorter
      @paulmcwhorter  2 года назад +1

      Ah Red Bull will probably kill you quicker than any of the others. Amazing to me living in a remote part of Africa, the syrupy drink pushers are already here trying to get folks to spend their hard earned money on sugary drinks.

  • @williamhyrkas698
    @williamhyrkas698 2 года назад

    Legend again

  • @trondnilsen4542
    @trondnilsen4542 Год назад

    My fault solution based on that Average already found did not work for if all grades are same(average).
    Had to struggle through many versions before i realized differece between range- and array-metode.
    So thanks to Paul for giving me the correct solution.
    NOT PERFECT: ...
    highest=0
    lowest=100
    for grade in grades:
    print('Innhold(karakter) : ', (grade)) #To track the iterations
    if (grade > Average and highest grade):
    lowest=grade
    print ('Din høyeste karakter : ', highest)
    print ('Din laveste karakter : ', lowest)

  • @vandanasrivastava2028
    @vandanasrivastava2028 3 года назад

    I am legend. I did that a bit differently by not adding 2 more for loops instead I added the 2 if statements in the first for loop

  • @ottawakravmagaacademy7013
    @ottawakravmagaacademy7013 3 года назад

    I AM LEGEND and proud to be learning Python

  • @bigbogeyface
    @bigbogeyface 3 года назад +1

    I spent nearly 3 hours trying to do this homework and folding up like a cheap garden deckchair 😔
    Then, after a few days, I decided to try again 🤨
    And, well, I'm not going to give the game array 🤭 I mean away!!! 🤦🤦🤦🤫
    But I'm now sitting back in my deckchair like a legend 😁 drinking a nice glass of ice tea 😋 🥃

    • @paulmcwhorter
      @paulmcwhorter  3 года назад +1

      Excellent! If at first you do not succeed, try try again.

    • @bigbogeyface
      @bigbogeyface 3 года назад

      @@paulmcwhorter The problem is when I put in two grade that are the same as eachother, then it doesn't work properly 🙄 🤷 🤦

  • @Vbeck56
    @Vbeck56 2 года назад

    I am LEGEND but I used min and max feature..... in my print statement. I just started typing and saw a min feature so i started to play with it.
    print('Highest Grade is: ',max(grades))
    print('Lowest Grade is: ',min(grades))
    but I added the for loop/if statement in because its import to learn more ways of doing the same thing.

  • @wendygrant2735
    @wendygrant2735 2 года назад

    It becomes easier every time, practise does matter. Legend.
    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])
    highest=grades[0]
    for k in range(0,numberGrades,1):
    if (grades[k]>highest):
    highest=grades[k]
    print('Your highest grade is ', highest)
    lowest=grades[0]
    for k in range(0,numberGrades,1):
    if (grades[k]

  • @catheria-clairebara9202
    @catheria-clairebara9202 Год назад

    What if we don't have any idea about lowgrade, everything depends on the user input.. how can that be handled?

  • @raavn0007
    @raavn0007 Год назад

    hello sir please the explain the concept ot Highgrades and lowgrades, because its very confusing.

  • @jstro-hobbytech
    @jstro-hobbytech 2 года назад

    i did it two ways haha one of the ways is the hw you've given us. bubble sort

  • @jdb222
    @jdb222 3 года назад

    Hello, the problem should disappear after saving the change..... observe the 'Explorer' icon (l/h upper corner of the VSC window)...but I also still do not know all the settings of VSC ;-)

  • @daveflatters4981
    @daveflatters4981 3 года назад

    I have manually done the highest/lowest and sorted the list. I don’t see the sense in doing like this though. There is a Max, Min and Sort function built into lists and arrays. These are probably more efficient and less prone to errors.

    • @paulmcwhorter
      @paulmcwhorter  3 года назад +1

      We can learn to think for ourselves, or we can offload the thinking to others using their functions. I am trying to teach people to think for themselves, as problem solvers are the ones who find the large salaries. For those interested, I am trying to teach how to logically work through a hard problem.

    • @whimsicalkins5585
      @whimsicalkins5585 2 года назад

      @@paulmcwhorter I 100% accept your point

  • @Ameer5CT
    @Ameer5CT 3 года назад

    If we use fewer for statements will that make the program faster ?

  • @arnaudmasse7839
    @arnaudmasse7839 2 года назад

    nailed it !

  • @yasararif8292
    @yasararif8292 3 года назад

    What happens if you wrote a grade giver than 100.
    Wouldn’t you need to stop the user making that mistake or prompting him to try a valid input.
    Regards

  • @polito-yd8fp
    @polito-yd8fp Год назад

    I am Legend this time round

  • @kalpeshpawar2201
    @kalpeshpawar2201 3 года назад +4

    Sir it's an grand request that please write an python code that converts pictures into string art and gives algorithm output please sir🙏🙏🙏🙏

  • @adirajchalotra
    @adirajchalotra Год назад

    I did it! I am legend!

  • @timothyj1962
    @timothyj1962 3 года назад

    I stopped in the middle to figure this one out. Seems one issue. We cannot assume that the highest grade would be 100. What if were based on 200? We can't up and rewrite the code every time the test has different scoring method. So we need to sort it out with the known variables. My method was to assume "lowScore=grades[0]" as a starting point. I placed that under the line of grades.append(grade). Then code "if (grades[i]

  • @mrelectronrock9510
    @mrelectronrock9510 3 года назад

    you are genius

  • @mikekeller7342
    @mikekeller7342 3 года назад

    Took a little bit, but I got it!

  • @frankfaubert1927
    @frankfaubert1927 8 месяцев назад

    I guess I'm a cheating legend.
    I just used Python's built in min(), max()
    '''maxGrade = max(grades)
    print('Your maximum grade is ', maxGrade)''"
    functions the first time through. I thought "Well,... this is incredibly easy. I must be doing something wrong." Sure enough, when I listened again to the end of lesson 9, you wanted us to use for loops. It took a lot longer but I got there eventually.