Python Tutorial 15: Solution to Python Pickle Homework Example Problems

แชร์
ฝัง
  • เผยแพร่เมื่อ 11 ธ.ค. 2024

ความคิดเห็น • 239

  • @proteopathy
    @proteopathy 2 ปีที่แล้ว +3

    I AM LEGEND. I made two separate programs. One to write the student data, the second to read and ask the user input. All of it was made to be non case-sensitive, with a clean layout. Love the realistic challenges you present. Very much a similar challenge to an intro to programming class one would encounter in college!

  • @directhubfeexam
    @directhubfeexam 3 ปีที่แล้ว +12

    Loved this lesson! I folded up like a cheap walmart chair (at least not a dollar general one) but this helped a lot! Thanks Paul.

    • @bola5671
      @bola5671 6 หลายเดือนก่อน

      Haha, that was kinda funny

  • @cbrombaugh
    @cbrombaugh 3 ปีที่แล้ว +2

    Your 78 year-old student is Legend! Keep up the great work Paul!

  • @aungphyokyaw4475
    @aungphyokyaw4475 5 หลายเดือนก่อน

    I did the homework! I am finally a legend. Sometimes I cannot do the homework 100%, I always try to do my best, and suffer. Thanks for pushing us.

  • @426F6F
    @426F6F ปีที่แล้ว

    I AM LEGEND!!! I was honestly a bit surprised when mine worked the first time around. Thanks, Paul, for all you do for everyone! You're the true legend, sir!
    I knew the receiver program would be the toughest part, and it took me about an hour or two to think through. I made an array called 'students' which stores the number of students as the first data type, the names as the second, and the grades as the final one.
    As the user inputs them and they are appended, the index of the individual 'grade' within 'grades' lines up with the index of the individual 'name' within 'names'. So I made a for loop to cycle through each name in the names array until it finds the string equal to the input name. Then, if the name is found, it uses that index for the same index as the grade. The program then prints out the student's name with the grade. It made it really easy!

    • @426F6F
      @426F6F ปีที่แล้ว

      Here's my code!
      import pickle
      i=0
      student=[]
      ans="Y"
      with open (c:/filePath/pickledStudentData.pkl','rb') as f2:
      student=pickle.load(f2)
      #print(student)
      #example [3, ['Paul', 'Karina', 'Vagan'], [100.0, 98.0, 65]]
      n=student[i]
      #print(n)
      #example: 3
      names=student[i+1]
      #print(names)
      #example: ['Paul', 'Karina', 'Vagan']
      grades=student[i+2]
      #print(grades)
      #example: [100.0, 98.0, 65]
      print(f"List of students: {names}")
      while(ans == "Y" or ans == "y"):
      namecall=input("Whose grade would you like to see? ")
      for i in range(0,n,1):
      if names[i] == namecall:
      grade = grades[i]
      print(f"{namecall}'s grade is {grade}")
      print("")
      ans = input("Would you like to see another grade? (Y/N): ")

    • @paulmcwhorter
      @paulmcwhorter  ปีที่แล้ว

      LEGEND!

  • @jonathanlanders9406
    @jonathanlanders9406 ปีที่แล้ว

    I AM LEGEND!
    I was unsure about where to go for this one, but I took several educated guesses and managed to get it right the first time (ignoring some minor syntax issues).
    I did it differently than Mr.McWhorter. Instead of making two arrays (one for the students and one for the grades) I built a single array that includes both. I show the code for my first file below.
    I originally used a for-loop in the second program to select out the data. I like this code, so I also posted the entire thing below (It includes good formatting of all printed text.).
    Lastly, not posted, I wrote the second program using a while-loop to select the data.
    The while(1==1) I added to both of my second programs after watching the video.
    Thanks for the great lessons!
    ###################################################### File 1: Creates Pickle File #########################################3
    #PaulMcWhorter - Python Beginners
    #Lesson 15: Saving and Reading Data Files With Pickle
    #The Write File: HWPickleA
    #by Jonathan Landers
    #May 20,2023
    ### Homework: Python File 1 ###
    '''
    This homework requires two python files.
    The 1st python file prompts the user for a list of student names and their average grades.
    The program saves this data in a pickle file as an array.
    The 2nd python uploads the pickle file and prompts the user for a student name.
    If the student name is in the data on the pickle file, the program gives the average grade of that student.
    '''
    #Import pickle library (included in python download).
    import pickle
    #Create Data.
    StudentNum = int(input('How many students do you have?:'))
    StGrad = []
    for j in range(0,StudentNum,1):
    x = str(input('What is your students name?: '))
    y = float(input("What is this student's average grade?: "))
    StGrad.append([x, y])
    #Create pickle file and dump data into it.
    with open('PaulMcWhorterPythonBeginners15HWPickle.pkl', 'wb') as p:
    pickle.dump(StGrad,p)
    pickle.dump(StudentNum,p)
    #Running the program will creat the pickle file.
    ############################# File 2: Uses Pickle File #########################################
    #PaulMcWhorter - Python Beginners
    #Lesson 15: Saving and Reading Data Files With Pickle
    #The Write File: HWPickleWhile
    #by Jonathan Landers
    #May 20,2023
    ### Homework: Python File 2 ###
    '''
    This homework requires two python files.
    The 1st python file prompts the user for a list of student names and their average grades.
    The program saves this data in a pickle file as an array.
    The 2nd python uploads the pickle file and prompts the user for a student name.
    If the student name is in the data on the pickle file, the program gives the average grade of that student.
    '''
    #Import pickle library (included in python download).
    import pickle
    #Upload pickled data.
    with open('PaulMcWhorterPythonBeginners15HWPickle.pkl', 'rb') as p:
    stgrad = pickle.load(p)
    stnum = pickle.load(p)
    '''
    Paul McWhorter's addition:
    We want this part of the program to run forever
    so that the user does not need to restart the program every time around.
    So, create a while loop that runs so long as 1 = 1, which is always true.
    '''
    while (1==1):
    #Ask user for student name.
    nameRequest = str(input('What is your students name?: '))
    st = 'nothing'
    grad = 0
    #Find out if requested name is in pickle file.
    #If data is in pickle file, create a variable for the student name and for that student's grade
    for i in range (0,stnum,1):
    if(nameRequest == stgrad[i][0]):
    st = stgrad[i][0]
    grad = stgrad[i][1]
    if(nameRequest != stgrad[i][0]):
    stnot = 'Name not in the list. Please enter a different name.'
    gradnot = int(0)

    #Print out the studen't name with their grade if available.
    #Otherwise, tell user that the student's name is not in the list.
    if(grad != 0 and st != 'nothing'):
    ststr = str(st)
    gradstr = str(grad)
    print('')
    print(ststr , 'has an average grade of' , gradstr + '.')
    print('')
    else:
    stnotstr = str(stnot)
    print('')
    print(stnotstr)
    print('')

  • @ModernDayWanderlust
    @ModernDayWanderlust 2 ปีที่แล้ว +1

    Legend. I'm starting to feel confident enough to add in some loops for things like re-prompting for the number of students if the inputted number is 0 or less than zero, prompting to display the student roster before recalling a student, and similar types of small improvements. I know there's a TON of ways I can optimize the code I'm writing, but I feel like each program I write is getting better, which is a really awesome feeling!
    As always, thanks Paul!

    • @paulmcwhorter
      @paulmcwhorter  2 ปีที่แล้ว +1

      LEGEND!

    • @ModernDayWanderlust
      @ModernDayWanderlust 2 ปีที่แล้ว

      @@paulmcwhorter I want to add that some Googling brought me to str.upper, str.lower, and str.casefold... super helpful to eliminate list recall errors caused by string punctuation!

  • @potatoz1137
    @potatoz1137 3 ปีที่แล้ว

    I am a LEGEND PAUL. I was so close to giving up but i wanted to be able to call myself a legend after being a lawn chair for so long so i kept thinking about it and reviewing our past assignments until it finally came to me like a bolt of lightning what to do :D. And now i am proud to say i have become a legend once again

  • @antrikshfulwani7087
    @antrikshfulwani7087 ปีที่แล้ว

    I AM LEGEND! I did something a little bit different:
    While entering the information about a student, I gave them a serial number, their name and their average marks.
    While reading, I gave them options to find the students' information using their serial number, name or average marks.
    Everything worked perfectly, because I understood everything perfectly, because you teach perfectly!
    Thank you for another amazing series.

  • @silver5970
    @silver5970 3 ปีที่แล้ว +7

    That was cool homework, i enjoyed doing it. It wasn't easy but it was doable!
    Love your work!

  • @rajeev01in
    @rajeev01in ปีที่แล้ว

    Very good Paul. I am sixty five years old without any prior coding experience. Found your way of teaching excellent. This particular exercise was tough to me. But i tried my best and could make the first part 'somewhat' a success; though i know that there is no 'somewhat' in this field. Thank you.

  • @EFoxVN
    @EFoxVN 2 ปีที่แล้ว

    "I am legend". But I could only do it after I allowed my brain to go into a different state. At first I had no clue what to do. And then later, inspiration came.
    And thanks, I really have a lot of fun!!
    Many blessings from South Africa!

  • @jeantorres3293
    @jeantorres3293 3 ปีที่แล้ว

    I am legend, I took python last year (currently a Junior in College) but I am amazed at how much you cover in such short time and with such clarity! Just have to strengthen my fundamentals with you

  • @raymondwood3603
    @raymondwood3603 ปีที่แล้ว

    First lesson in Python Tutorial where you've asked us to hold our breath. My kids and I have been waiting for it.

  • @RobVollmar
    @RobVollmar 3 ปีที่แล้ว +2

    Paul,
    I used a slightly different tack in the second program. Rather than creating an array for numGrade, I handled the indexing like this:
    j=0
    student=input('Which students average would you like to check? ')
    for i in stuArray:
    if (student==i):
    print(student,'has an average grade of ',avgArray[j])
    j=j+1

    • @Leonarco333
      @Leonarco333 2 ปีที่แล้ว

      Similar to how I did it. It seemed like an elegant solution.

    • @jstro-hobbytech
      @jstro-hobbytech 2 ปีที่แล้ว

      Funny how many ways to do it. I used just a while loop with an escape character so it only had to be a couple if statements incase the person didn't exist.

  • @jbelmont72
    @jbelmont72 ปีที่แล้ว

    I combined both programs into one with a combination of if /elif and input options. appended a data set and made the counter into a string which became the student ID. Thus could locate the student by student ID or any of the elements in each "appended "list. Really enjoyed this.

  • @kamwilliams9085
    @kamwilliams9085 2 ปีที่แล้ว

    I AM LEGEND!!! lol Finally after unsuccessful attempts these past few assignments. My syntax isn't as complex as yours, I didn't include the name in the response but It worked so its a moral win for me!! I will include your pro tips next time.. Thanks!

  • @opalprestonshirley1700
    @opalprestonshirley1700 3 ปีที่แล้ว +1

    Mine was a bit different but yours was a bit simpler. Great job Paul.

  • @nicholastan8478
    @nicholastan8478 3 ปีที่แล้ว

    I am legend. This took a while for me as i put everything into one list before dumping. happy to see different solutions

  • @sherlocksrobot1455
    @sherlocksrobot1455 2 ปีที่แล้ว

    I did it! That was a fun challenge. I decided to pickle a 2D array, but then I had to look into how to reference it. It wasn't until you passed the array size that I realized how useful that can be for error checking. I'm used to using rectangular datasets, so the ability to pass a single integer at the top is stretching my brain.

  • @hughpatterson1480
    @hughpatterson1480 2 ปีที่แล้ว

    Another great lesson Paul. I've been able to do the homework thus far. While I would say "I am Legend," I did study this when I went back to school to get a degree in IOT design and prototyping (just so I could build SDR ham radios and teach). It also took me a few tries....Thank for another great lesson! I will pass this on to my students!

  • @ECE_Engineering
    @ECE_Engineering 3 ปีที่แล้ว +4

    As always, I love your tutorials. Thank you.

  • @madsci6807
    @madsci6807 ปีที่แล้ว

    I am legend! easier than the last assignment. Separated it into two programs, one for the input, and one to retrieve the data. got a little messed up at first with the pickle storage, but figured it out.

  • @wendygrant2735
    @wendygrant2735 2 ปีที่แล้ว +1

    This was fun indeed. Learnt a lot again. Thank you, Sir.

  • @benthompson6118
    @benthompson6118 2 ปีที่แล้ว

    Great lesson Paul. In working through the homework I wanted to be able to leave myself notes in the program to come back to in the future and learned about the "#" to leave comments on lines. I think it would be awesome to mention that in the first few lessons so people can leave themselves notes.

  • @gediminasgresevicius2901
    @gediminasgresevicius2901 2 ปีที่แล้ว

    This time i made it! So good feeling. I made it in one program, and then split them in two. It works :)

  • @ylevite
    @ylevite ปีที่แล้ว

    LEGEND! Managed to do homework. I have never in my life done homework willingly :)

  • @mohsenr4434
    @mohsenr4434 2 ปีที่แล้ว

    I did a more complicated homework and almost gave up before I could finally debug it even after watching this lesson for the second time haha.. But I finally did it. Thank you!

  • @bkairosh8164
    @bkairosh8164 3 ปีที่แล้ว +1

    Quite keen to find out more information on accepting data from the web, arduino or other external sources, process them on Python and send them back for further action. Thank you Paul for all the lessons. Greeting from Kazakhstan.

  • @Leonarco333
    @Leonarco333 2 ปีที่แล้ว

    Boo yeah! Even overachieved a bit.
    I simplified the data transfer by condensing the student and grades vectors into a matrix and read the length in the new program. I used the same trick to use names in the input statements and in the second program I added a view all option to print all of the names and grades in a table.
    Using while loops instead of for loops made the formatting easier while calling corresponding indices in the matrix to keep names and grades together.

  • @0Mr.Java0
    @0Mr.Java0 ปีที่แล้ว

    I am legend! As always your lessons are great Paul! You are my go to for programing. I started with your Arduino lessons and got hooked! Can't wait to get you your Visual Python 3d Graphics and Animation.

  • @timothyboyd4346
    @timothyboyd4346 3 ปีที่แล้ว

    I am legend! This was the first time I've gotten pickle to work thank you!

  • @DeNihongoAsobou
    @DeNihongoAsobou 3 ปีที่แล้ว +1

    It took time,but I did my homework!So fun.Thanks Paul

  • @mateobertin3376
    @mateobertin3376 2 ปีที่แล้ว

    I fold up like a che... I AM LEGEND PAUL!!! THank you for your incredible lessons, I see your videos from Argentina.

  • @davidschnider1297
    @davidschnider1297 ปีที่แล้ว

    thanks, Paul .. looking forward to Functions, Methods and Classes... yes having FUN... blessing so you...

  • @soundarrajankannan7692
    @soundarrajankannan7692 3 ปีที่แล้ว

    I did my homework and solved it too.All thanks to you.

  • @starRunnerX
    @starRunnerX 2 ปีที่แล้ว

    I am a baby Groot legend. I easily got the first part, yet could not figure out the last half of the second HW. Your if statement, inside a for loop, inside a while loop really through me for a loop! I could envision something like that, I just could not for the life of me make it work with a string, instead of an int. I have now joined your Patreon. Thank you Mr. Paul, your tutorials have really helped me out. Would a robotics with Python every be a thing you'd do?

  • @jaeyounghong8099
    @jaeyounghong8099 2 ปีที่แล้ว

    My code was similar, and my code worked perfectly fine. However, I didn't input dump and load print the data using two different programs. Although I understood this assignment, I am not satisfied because I watched your solution video before finishing the 2% left. Hopefully next time, I'll fully do it on my own.
    Thanks for the python lessons, Paul!
    Here after completely all the Arduino lessons~

  • @martinlewis645
    @martinlewis645 3 ปีที่แล้ว

    Took me a while. I had to walk away and come back the next morning. Legend.

  • @berryblades
    @berryblades 2 ปีที่แล้ว

    I AM LEGEND! Back into it again and loving Python Paul, this was fantastic, its starting to feel like I may someday be able to write something that has real world use!
    I'm here after the New Arduino sessions and its about time I became a patreon and contributed something, I wanted to give you a small bulk donation to show my appreciation when I finished the Arduino sessions but TH-cam wanted to tax it so that's no good. I will give what little I can through Patreon though!

    • @paulmcwhorter
      @paulmcwhorter  2 ปีที่แล้ว

      LEGEND! Appreiate the interest in helping out. Also, my paypal is paul.mcwhorter@gmail.com . For some people that is the best way to help.

  • @mikew877
    @mikew877 3 ปีที่แล้ว

    Got the homework assignment to work!! It was fun!

  • @jopiehattingh5351
    @jopiehattingh5351 11 หลายเดือนก่อน

    Thank you very much the time and effort you put into the lessons Paul. Just happend to stumble upon yout lessons and learning a ton! I'm sure that like myself it's really appreciated by many. I must be honest it did not dawn on me to simply pickle the value for the number of entries to repeat and read it in for my loop in the read program. I ended having to do a bit reading/cheating and ended up using "len" to get the size of the array/list. Seems kind of obvious once I saw your solution...and so we learn :-) After getting it working tried to be a little morw fancy and add to the lesson by putting in a loop in to repeat the request for a name and display "not found" should the student name be entrered incorrectly or doesn't exit but admittedly folded pretty bad there. Looks like a little more loops and if statement practice is required and of course "fuel.

  • @TheFleetz
    @TheFleetz 3 ปีที่แล้ว +3

    Hope things are going well for you in South Africa Paul.

  • @obinnaomeje2479
    @obinnaomeje2479 3 หลายเดือนก่อน

    Finally did an assignment right on my own😅😅 right... I AM LEGEND🤗🤗
    Sir paul thank you for your efforts... i am a from Nigeria... trust me the education system is totally messed up... your videos are currently helping me help my life. thank you and may God bless you🙏

  • @danielsaenz5570
    @danielsaenz5570 2 ปีที่แล้ว

    I am LEGEND!! Thanks for all these lessons!!!

  • @colepdx187
    @colepdx187 2 ปีที่แล้ว

    Fun assignment. I added some functionality. Normalized 'name' using the capitalize() method, added 'list' feature to list all records. Used rjust() and ljust() methods to nicely format the output of the list. Program loops until a blank name is entered in case you don't know how many names you have to enter and/or want to display multiple records. There's still this huge elephant in the room that if you enter a string at the grade prompt there is an unhandled program exception.

  • @chalmerditmars7037
    @chalmerditmars7037 ปีที่แล้ว

    I did it quite a bit different than you. I stored the student and grade in pairs in a data file and only pickled 1 file. Then I used len of that file to get my range of i and did not run the loop forever. In the loop it pulled the pair and checked the first half for match with the name that was input and then I printed "The average grade of x is y. Good lesson. I notice you only have about half as many likes now. Did some of those guys go down in their lawn chair and still laying out in the Walmart parking lot?

  • @brandendowning1714
    @brandendowning1714 ปีที่แล้ว

    Legend! Thanks Paul! This was a fun one!

  • @architjain1908
    @architjain1908 3 ปีที่แล้ว

    I put all the names and grades in one array as they are inputted so there every two entry is a name and other every two is the grades right after the name. For, "if name==names[i]", I out i as increments of two and if the asked name was the name, then the grade would be [i+1]. Hope that works great as well. Thank You!!

  • @tiberiumihaescu5382
    @tiberiumihaescu5382 2 ปีที่แล้ว

    I am Legend! Good to finally be back on track!

  • @kingdavid_p
    @kingdavid_p 3 ปีที่แล้ว

    I am legend. And I am finally caught up with your python tutorials. See you next week

  • @pennyshen5269
    @pennyshen5269 2 ปีที่แล้ว

    Really love ur style sir.thanks a lot 😀!

  • @Captain_Vitorio_Muscovy
    @Captain_Vitorio_Muscovy 2 ปีที่แล้ว +1

    I chose to use only 1 list, personal preference.
    My code for the programs bellow:
    Program 1
    import pickle
    num_students = int(input("How many students you have?: "))
    student_grade_list = []
    N = 0
    while N < num_students:
    student_name = input(f"Please input the name of student nº{N+1}: ")
    student_grade = float(input(f"Please input {student_name}'s grade: "))
    student_grade_list.append(student_name)
    student_grade_list.append(student_grade)
    N += 1
    with open("Student_Data.pkl", "wb") as SG:
    pickle.dump(student_grade_list, SG)
    Program 2
    import pickle
    student = input("Please inform the student's name: ")
    N = 0
    with open("Student_Data.pkl", "rb") as SG:
    name_grade = pickle.load(SG)
    while name_grade[N] != student:
    N += 1
    if name_grade[N] == student:
    print(f"{student}'s grades average is {name_grade[N+1]}")

  • @dadrbaa9850
    @dadrbaa9850 2 ปีที่แล้ว

    amazing ! Engineer . I love your way of Explaining. you made me so excited of Programming language and python 😍

  • @maku5289
    @maku5289 2 ปีที่แล้ว

    I am NOT legend... damnit was so close but I forgot to write 'range' in my loop of program 2, was surprisingly working for 3 and below, but over 4 students it would bug. 5-day-in-a-row 💥☕ Amazing content as always. 🤟

  • @boydrogers7227
    @boydrogers7227 3 ปีที่แล้ว

    Nearly identical to mine. 2 notable differences: 1. Instead of "while(1==1):" I used "while(studentName!='x')" to give myself a way out of the program. 2 instead of a "for" loop for comparing the entered name to the list, I used a "while" loop with i=i+1 iteration so that when I got a match, I could set my iterator to max and quit comparing. Also after I watched your solution I switched from commas to pluses in my strings to eliminate unwanted spaces. BTW, the concatenation works with just the variable name, i.e. "print(name+"'s grade is "+grade)".

  • @pralaymajumdar1206
    @pralaymajumdar1206 3 ปีที่แล้ว

    Learn a lot sir.. Thank you. waiting for the next week.

  • @patis.IA-AI
    @patis.IA-AI ปีที่แล้ว

    again great simple comprehensif top dot "nounours"

  • @ernestomendoza4862
    @ernestomendoza4862 3 ปีที่แล้ว

    I am a legend! I did it a little differently. My array elements are vectors of three elements, the student ID, the student name, and the student grade. Then I can a specific name / grade by selecting the ID.

  • @mahadf9321
    @mahadf9321 2 ปีที่แล้ว

    Amazing video like always!

  • @jstro-hobbytech
    @jstro-hobbytech 2 ปีที่แล้ว

    This homework was cool. I built on everything we already did except the +name+ to keep on the same line. I couldn't get that part so the output wasn't perfect.
    I used a while for the second program with an escape character. I got away without a a loop within a loop.

  • @DrJALAGHARI
    @DrJALAGHARI 3 ปีที่แล้ว

    Thank you so much for sharing this valuable information through this amazing video.

  • @polito-yd8fp
    @polito-yd8fp ปีที่แล้ว

    I was able to do it but using while loops, for loops seemed a little hard at first so I understood after I watched you now 😂

  • @DivyanshAgarwal-cj3ur
    @DivyanshAgarwal-cj3ur 5 หลายเดือนก่อน

    Just love your vedios
    Learning alot from your tutorial s❤

  • @RDKCREATIONS
    @RDKCREATIONS 3 ปีที่แล้ว +1

    Hi sir can you add a series of kali Linux

  • @jimsimpson1006
    @jimsimpson1006 11 หลายเดือนก่อน

    Output of the first program:
    How many students are in the class? 3
    Please enter the student's name: James
    Please enter the student's average mark: 90
    Please enter the student's name: Alice
    Please enter the student's average mark: 92
    Please enter the student's name: Bob
    Please enter the student's average mark: 93
    Thanks, that's all the data entered
    Output of the second program:
    Which student's average mark do you wish to see? Alice
    Alice obtained an average mark of 92.0
    I learnt A LOT from this lesson, especially about saving data to a file. It’s getting to the stage where we can start doing actual useful stuff with Python!

  • @amayaphotos8016
    @amayaphotos8016 ปีที่แล้ว

    At first i forgot to do the load stuff, but then i figured it & yeah, I AM A LEGEND

  • @legend1204
    @legend1204 3 ปีที่แล้ว

    I AM A LEGEND!!!!! Thanks Paul

  • @bola5671
    @bola5671 6 หลายเดือนก่อน

    I just want to drop a little love

    • @paulmcwhorter
      @paulmcwhorter  6 หลายเดือนก่อน

      Thanks, I really appreciate the support, it means a lot!

  • @codecage9333
    @codecage9333 3 ปีที่แล้ว

    Anxiously awaiting the solution to see how my program compares.

  • @edSabio572
    @edSabio572 3 ปีที่แล้ว

    Outstanding!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

  • @TheScissorunner
    @TheScissorunner 2 ปีที่แล้ว

    Because of Huckleberry! I am Legend!
    Amazed by how the print statement can help with understanding what the code is doing.

  • @vysakhak191
    @vysakhak191 2 ปีที่แล้ว

    I recommended this tutorial series to two of my best friends.😎

  • @arnaudmasse7839
    @arnaudmasse7839 2 ปีที่แล้ว

    was able to do it on my own ! I am legend!!!!

  • @advancedperformance9721
    @advancedperformance9721 3 ปีที่แล้ว

    Thank you sir God bless you 🙏

  • @railcat7083
    @railcat7083 3 ปีที่แล้ว

    Legendary, dude!

  • @samuelsavangouder5102
    @samuelsavangouder5102 2 ปีที่แล้ว +1

    Hey Paul, can I use a while loop to take the input(names and marks) from the user?
    Instead of the for loop as you did.
    Ex:
    j = 0
    while (j < numStudent):
    ....
    ....
    ....
    j += 1
    Is this the correct way of doing it?

  • @robinwood5833
    @robinwood5833 3 ปีที่แล้ว

    Thank you Paul, lessons are fantastic
    from Robin Downunder

  • @terrymurphy565
    @terrymurphy565 2 ปีที่แล้ว

    I am Legend, looking forward to see if I did it the same as you.
    My program was very similar, used while instead of for loop.
    Also direct append my inputs using name.append(input('Please Enter Name: ')) this saves one line of code. Not sure if this could cause issues or not. Used this in previous lessons as well.

  • @maggit13
    @maggit13 2 ปีที่แล้ว

    I am LEGEND!! total beginner at this and I got it to run. I also added in if the name is invalid, it says it's not in the list. Also added asking if the user wants to continue entering names, if not, it drops out of the while loop. Is it possible to use data sets like you had in the last lesson and have it search through multiple arrays instead of using separate arrays as the variables? or is that more advanced? Thanks again Paul!

  • @ricardobjorkeheim775
    @ricardobjorkeheim775 3 ปีที่แล้ว

    nice solution Paul:)

  • @patfacunla1687
    @patfacunla1687 3 ปีที่แล้ว

    I am legend Paul thanks to you!!!

  • @darryng
    @darryng 3 ปีที่แล้ว

    Excellent Tutorials! Busy with the Jetson Nano! Is there any chance you could do a series on the ESP32 with the ESP-IDF on VS Code? Much Appreciated!

  • @scrappybobbarker5224
    @scrappybobbarker5224 3 ปีที่แล้ว

    Thanks for the Video!

  • @criptosauro4587
    @criptosauro4587 ปีที่แล้ว

    the "while 1==1" is to keep asking,
    I solved the Homework this way:
    import pickle
    #get the info out
    with open("datos de los estudiantes.pkl", "rb") as f2:
    N= pickle.load(f2)
    G= pickle.load(f2)
    print(N)
    print (G)
    # What student are you interested in?
    ask = input("What student are you interested in? ")
    student_num = N.index(ask)
    print("The grade of", ask , "is: ")
    print(G[student_num])

  • @jayarrcole5907
    @jayarrcole5907 3 ปีที่แล้ว

    Hi Paul. How to exit the while loop?

  • @charlielowell4077
    @charlielowell4077 2 ปีที่แล้ว

    I might have missed where you mentioned it, but I didn't realize that I could use the same "for" loop to input both the name and the grade at the same time. For some reason I misunderstood that a for loop was only used for a single operation. I spent an hour trying to figure out how to associate name[n] with grade[n] after they had been put in their respective lists as a result of passing through two separate for loops. Finally gave up and watched your code. Really don't feel like a lawn chair after that, though. Really.

  • @Mahin9994
    @Mahin9994 11 หลายเดือนก่อน

    I AM LEGEND! And
    'YOU ARE A GENIUS in ART OF TEACHING'!
    Stay Blessed and LiVE LoNG!!!

  • @LandNfan
    @LandNfan 2 ปีที่แล้ว

    Rather than iterating through a potentially long array, why not use the index() function to locate the desired name? (Yeah, I was always the guy who read ahead in the handout and was usually two exercises ahead of the instructor.)
    Another question: have you ever played with multivalue databases like Pick, Unidata, JBase, or OpenQM? OpenQM is implemented on Windows, MacOS, AIX, several flavors of Unix, many Linux distros, even on Raspberry Pi. Multivalue is tremendously flexible and very economical on system resources. All data files are stored as variable length delimited values with hashed access. Programming is in a supercharged version of the language most of us older guys learned in the late ‘70s, BASIC. Dictionaries are used for ad hoc command line queries, but not required in programs. Best of all, a single user personal version of OpenQM is free.

  • @DrazelR
    @DrazelR 2 หลายเดือนก่อน

    You're the best!

  • @briangraham910
    @briangraham910 11 หลายเดือนก่อน

    Great lessons! When I alter the code, (I have autosave on), the program doesnt update. All the other programs are fine but for this one I literally need to close VS Studio and reload the program to reflect changes. I found out the hard way...I tried to code it myself, but it was always giving me errors. I would update the code but get the same error. After realizing the results weren't changing, I reopened VS Studio and viola! I tried to add code that if you enter a name not in the list, it would return a print("No records found" but I wasn't successful. I gave up because everytime I add or remove code I need to close and reopen VS Studio. Any thoughts? Thanks

  • @atesotheater6536
    @atesotheater6536 3 ปีที่แล้ว

    Thank you 😊

  • @steveholt8991
    @steveholt8991 4 หลายเดือนก่อน

    Yes, I'm legend. Fairly easy, pickle is a great interface.

  • @bassman2162
    @bassman2162 3 ปีที่แล้ว

    If you put \b in the string it will not put the space
    print(name, “\b’s grade is “,grade[i],’\b.’)

  • @DrewCreate
    @DrewCreate 2 ปีที่แล้ว

    I’m struggling to understand the point of the while 1==1
    If that’s gonna always run no matter what why is it necessary?
    Sorry if that’s a dumb question!
    I’ve really been enjoying these lessons, thanks for all your hard work putting them together!

    • @DrewCreate
      @DrewCreate 2 ปีที่แล้ว

      My natural instinct was to do
      For I in range (0, numGrades, 1):
      Name=input(“which student do you want to check”)
      If names[i]==name:
      Print(name, “‘s grade is”,grades[i])
      With no while 1==1

  • @gediminasgresevicius2901
    @gediminasgresevicius2901 2 ปีที่แล้ว

    Hi Paul, this is my second comment under this video.
    I would like to figure out one thing about for loop - when I should define range for it, and when not? I'm a bit confused. Maybe You pointed that in your lectures, but I missed it out. I was writing two parameters in to file - names and greads. To find the name and in what index it is I run the for loop. But I had to define the range
    "for i in range(0,numStud,1)". As I did not write number of students in to file, I had to find it by running onother for loop
    "for i in studens:
    numStud=numStud+1"
    So why it works in one loop, but not in other? Why it ask me to define range instead of just accepting one for loop with students names array "studens"?
    Not sure is my question is clear... but I hope you will find time to answer here or maybe in some video lectures.
    All the best

  • @queue4020
    @queue4020 3 ปีที่แล้ว

    Instead of creating a “name” and a “grade” array at the beginning, I made a single “students” array. Then I created a “studentInfo” array within the while loop, initialized “studentName” variable input, then appended it, and did the same with a “studentGrade” variable. Can you tell just by this if it Is more or less efficient?

  • @joansome951
    @joansome951 ปีที่แล้ว

    Hey guys, how can I break the while loop in the second program?

  • @yourijpl
    @yourijpl 3 ปีที่แล้ว

    let's say I am a legend however mine version of homework was as twice as long as here.
    For a very simple reason. I decided to store my data in a single array: [name1, grade1, name2, grade2, name3, grade3...] so on the end while reading it I used new arrays in the code to retrieve from this mess I made myself.
    So one thing is a simpe code but other is the way we store our data. Bad choice on the beginning made my code very long on the end :)
    But it worked so... ;)

  • @ΜοσχουΤελης
    @ΜοσχουΤελης 3 ปีที่แล้ว +1

    Mr Paul I didn’t pickle.dump the number of students, I just dumped the arrays names and grades because I can the len() function in the second program.