Python Tutorial 15: Solution to Python Pickle Homework Example Problems

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

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

  • @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 3 месяца назад

      Haha, that was kinda funny

  • @proteopathy
    @proteopathy 2 года назад +4

    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!

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

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

  • @RobVollmar
    @RobVollmar 2 года назад +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.

  • @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 года назад +2

      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!

  • @silver5970
    @silver5970 3 года назад +7

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

  • @aungphyokyaw4475
    @aungphyokyaw4475 2 месяца назад

    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 10 месяцев назад

    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 10 месяцев назад

      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  10 месяцев назад

      LEGEND!

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

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

  • @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.

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

    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.

  • @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

  • @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.

  • @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('')

  • @obinnaomeje2479
    @obinnaomeje2479 13 дней назад

    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🙏

  • @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?

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

    As always, I love your tutorials. Thank you.

  • @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

  • @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!

  • @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!

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

    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.

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

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

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

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

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

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

  • @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.

  • @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?

  • @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.

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

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

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

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

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

    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.

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

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

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

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

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

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

  • @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!

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

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

  • @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.

  • @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.

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

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

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

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

  • @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.

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

    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~

  • @jopiehattingh5351
    @jopiehattingh5351 7 месяцев назад

    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.

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

    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 RUclips wanted to tax it so that's no good. I will give what little I can through Patreon though!

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

      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.

  • @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.

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

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

  • @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!

  • @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?

  • @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!!

  • @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.

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

    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!

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

    Hi sir can you add a series of kali Linux

  • @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 😂

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

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

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

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

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

    Legend! Thanks Paul! This was a fun one!

  • @Captain_Vitorio_Muscovy
    @Captain_Vitorio_Muscovy Год назад +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]}")

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

    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. 🤟

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

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

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

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

  • @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)".

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

    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.

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

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

  • @patis.IA-AI
    @patis.IA-AI Год назад

    again great simple comprehensif top dot "nounours"

  • @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.

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

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

  • @DivyanshAgarwal-cj3ur
    @DivyanshAgarwal-cj3ur 2 месяца назад

    Just love your vedios
    Learning alot from your tutorial s❤

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

    Really love ur style sir.thanks a lot 😀!

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

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

  • @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!

  • @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.

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

    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 Год назад

      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

  • @user-qn1mh5oj9r
    @user-qn1mh5oj9r 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.

  • @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])

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

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

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

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

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

    Anxiously awaiting the solution to see how my program compares.

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

    Amazing video like always!

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

    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

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

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

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

    I AM A LEGEND!!!!! Thanks Paul

  • @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.

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

    I managed to do the homework. Did slightly different from you in that instead of using for in range loop I used while loops. Otherwise everything was pretty similar.

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

    I did mine a little different because I wasnt sure if i need to source which array i was pulling data from. So i created a new array with the two pulled arrays. But here is how I did it.
    studentRequest=str(input("Please Enter Your Students Name: "))
    studentsCred=[[studentsName,studentsAverage]]
    for i in range(0,totalStudents,1):
    if (studentRequest) == (studentsName[i]):
    print (studentsName[i],"'s Average is: ",studentsAverage[i])

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

    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

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

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

  • @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!

  • @Mahin9994
    @Mahin9994 7 месяцев назад

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

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

    Thanks for the Video!

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

    Thank you sir God bless you 🙏

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

    I am legend Paul thanks to you!!!

  • @Joel-pl6lh
    @Joel-pl6lh 3 года назад

    I did not know I had to create another file, so I paused the video and did it (Because I am a legend). I also added an option to exit the program and a message in case the name entered does not exist in the pickle file

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

    I am legend thankyou sir may god bless you

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

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

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

    Thank you Paul, lessons are fantastic
    from Robin Downunder

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

    Well, this might just get me out of a pickle. Sorry, I had to do that. I was wondering how I would save the safe combination that was running in the event of a crash or some other unforeseen catastrophe. What if I’m on the 12,385 combination try and the power goes out? I don’t want to start at number 1 again! If my pickle is in a while loop will it rewrite the new data over the old? I think I just need to save the ID number that is currently running. I can’t wait to start playing with this.

  • @steveholt8991
    @steveholt8991 Месяц назад

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

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

    Please add a lecture in arduino lecture series with video on using 4*4 keypad with arduino.

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

    I was able to do it. I had one syntax mistake that wasn’t any where near where the error message showed. But I found it

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

    i just use one array for name and avg, and i use the len fonction to know the length, Work just fine with less code

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

    I took a slightly different approach. I used the Index function to return the index value of the student name and then passed that value on to pull the grade from the grade array. So, I am sort of legendary, perhaps not LEGEND... 😉