Python Tutorial 19: Python Classes and Methods Homework Examples

  Рет қаралды 16,906

Paul McWhorter

3 жыл бұрын

You guys can help me out over at Patreon, and that will help me keep my gear updated, and help me keep this quality content coming:
www.patreon.com/PaulMcWhorter
In this video we show step-by-step instructions on how to understand and use Python Classes and Methods. We write demonstration code and give examples and solutions. We present solution programs to the homework in Lesson 18 I do not assume you are an expert, so these lessons are designed for complete beginners.
#Python
#Lessons
#Programming

Пікірлер: 176
@irete267
@irete267 Жыл бұрын
I am legend. Took 60 lines of code and a whole day of brainstorming to do it all which I am not use to at all yet. I also realized if you put the prompt in the init method, the code will ask for grades for all the students and store them accordingly. That's actually what I did first before watching your video again and did exactly what you told me to. This is why it is good to do things on your own, whether you know it or not it helps broadens your understanding.
@paulmcwhorter
@paulmcwhorter Жыл бұрын
LEGEND!
@EFoxVN
@EFoxVN Жыл бұрын
"I am legend!". I finally got this right after folding up 4 months ago due to a silly error. I tried again. I love these classes about classes. They came difficult to me too, but I guess I am slowly getting this. YAY! Sometimes it helps to give something a break.
@bassman2162
@bassman2162 2 жыл бұрын
I was able to do it! I even coded it so that the students were in a loop 0 to numStudents so I didn't have to make up instances like stud1, stud2. I just worked inside the loop with std[i]=student. I thought that's what you were asking for in the assignment. It has a method to calculate average grade, low grade and high grade for each student. It has a method to use nested loops to print out the entire list of std[i] with each one's grades (scores[j]). I'm thinking of adding a method to find/print a single student name provided by the user. Anyway, it works like a champ.
@Wythaneye
@Wythaneye 3 жыл бұрын
Legend. It was definitely the lengthiest assignment so far, but by golly, it works!
@pralaymajumdar1206
@pralaymajumdar1206 3 жыл бұрын
You are really a very good teacher, I learned a lot from you sir. I want to learn much more from you. Please teach us all from your full of wisdom. Thank you.
@paulmcwhorter
@paulmcwhorter 3 жыл бұрын
So nice of you
@zoltantakacs3812
@zoltantakacs3812 Жыл бұрын
Thought to much about how to loop through and asking for the student names and grades in one setting, instead of just passing the first and last name to the class. After couple of hours I realized that I had the solution already figured out. Immersing yourself into the topics...even when it takes me hours to figure it out...does help to gain a better understanding. Thank you for keeping us motivated to become legends!
@bharathr110
@bharathr110 2 жыл бұрын
I was able to do it all on my own! I didn't even google for help!! Thank you so much Paul for your excellent lessons and of course I AM LEGEND!!
@paulmcwhorter
@paulmcwhorter 2 жыл бұрын
Great job!
@aviralsoni8749
@aviralsoni8749 3 жыл бұрын
Sir you are a great teacher. I learned very good arduino with help of your videos! Please don't stop teaching online. World needs teachers like you
@paulmcwhorter
@paulmcwhorter 3 жыл бұрын
Thank you, I will
@chrisb7250
@chrisb7250 6 ай бұрын
I absolutely love these lessons. They have given me confidence and have really helped me understand how many useful systems in today’s society work. Thank you Paul for all of these amazing lessons. I wish you many more years of health and happiness.
@pokerface68
@pokerface68 2 жыл бұрын
This was a lot of fun, I was very close to your solution with the biggest change being how I printed out the grades as an array instead of printing each individually - I guess I did not quite understand what you were looking for. All in all, I am very pleased!
@opalprestonshirley1700
@opalprestonshirley1700 3 жыл бұрын
Finally, have the lesson done and set in my head. Thanks, Paul.
@paulmcwhorter
@paulmcwhorter 3 жыл бұрын
Glad to help!
@NOS187
@NOS187 2 жыл бұрын
It took me a while to wrap my head around everything. But once I did it flowed really fast and made a ton of sense! I AM LEGEND!
@ecassar1975
@ecassar1975 2 жыл бұрын
I struggled with the homework this time round but in the end I managed to come up with a solution. I need to tweak some things now that I have seen your solution. For example I didn’t know that I could put the high grade and the low grade the way you did it. Instead I placed two lines of code, one saying highGrade = highLow[0] and another saying lowGrade=highLow[1]. I also went a bit beyond by creating a pickle to place the students names in a file rather than placing them in the code. Don’t know if I can call myself legend this time round but I feel that I’m learning a lot and grasping all concepts thanks to your excellent tutorials. Thanks a lot.
@tntragan
@tntragan Жыл бұрын
I am legend. Took quite a while. Got hung up with returning multiple variables in the highLow grades. Finally figured out I needed to separate the high and low in the main program. Thanks for the great lessons. I'm learning alot. Already been through your arduino lessons. Just got my gear for the raspberry pi lessons and I have the kit for the raspberry pi pico w you will be doing this coming year. Looking forward to that one. Tom
@railcat7083
@railcat7083 2 жыл бұрын
Legendary, great introduction to objects/methods! I have never before had a clue about OOP.. Great stuff!
@paulmcwhorter
@paulmcwhorter 2 жыл бұрын
Glad it was helpful!
@jakesanchez3552
@jakesanchez3552 2 жыл бұрын
After a long time of avoiding OOP i finally have an idea of how classes work. There is a great little piece of OSS called MeerK40T (pronounced meerkat) that i use with my K40 co2 laser engraver, i have a few ideas I'd like to implement but my progress has been slow and painful considering I'm having to work around a programming style i was completely unfamiliar with. This series was great and i look forward to learning more from you. Thank you Paul!
@ModernDayWanderlust
@ModernDayWanderlust 2 жыл бұрын
It took me a few days of playing with this to really wrap my brain around it, but in the end I'm legend, and once it clicked it went pretty quickly. I went about it a little differently than you did. I put a third attribute (self.grade_values) into the Student class, and set it to equal my self.grades_inpt method which prompted for the number of grades, the grade values, and then sorted the grades. That let me only enter the first and last names of the students and did the rest via input before spitting out the various methods. I think I'm going to write up the whole mess again but this time put the individual students into an array which (I think lol) should let me more easily add additional students. This one was fun. I struggled for sure, but it's way clearer now!
@jonathanlanders9406
@jonathanlanders9406 Жыл бұрын
I am a legendary fold-up chair. I was struggling to visualize how the user was supposed to interact with the data, so I watched Mr. McWhorter start the program. I then did the bulk of the code on my own, but checked my work with the video as I went. Looking forward to graphics and AI!
@martinc9215
@martinc9215 Жыл бұрын
I did the same as you
@fjrdavinautomationabregana5733
@fjrdavinautomationabregana5733 3 жыл бұрын
Sir good morning, thank you very much that i am the one your followers for your vlog sir. It can help me for my carrier now as a contractor. Infact im beginers for arduino programing sir, but in plc, hmi and motor control i know cause that is my pevious work since i was working for industrial company. Thank you very much sir, you are good teacher or facilitator because you have and full methodology of teaching that easily get by the viewers.
@paulmcwhorter
@paulmcwhorter 3 жыл бұрын
Best of luck
@lewismeyer4452
@lewismeyer4452 3 жыл бұрын
Legend, great video, struggled with concept for classes and methods.
@paulmcwhorter
@paulmcwhorter 3 жыл бұрын
Glad it helped!
@saliferous5161
@saliferous5161 3 жыл бұрын
learned so much from you. thank you so much!
@paulmcwhorter
@paulmcwhorter 3 жыл бұрын
Happy to help!
@pralaymajumdar1206
@pralaymajumdar1206 3 жыл бұрын
Extraordinary, enthralled.. Thank you sir.
@paulmcwhorter
@paulmcwhorter 3 жыл бұрын
Most welcome!
@robertbliss1677
@robertbliss1677 Жыл бұрын
I really appreciate the mistakes, because then I get to follow along with the debugging process. I learn how to fix things when they break.
@williamhyrkas698
@williamhyrkas698 2 жыл бұрын
After 2 days of work I am legend. I will go back and concatenate some of my input and print strings to include hyphens. Thanks for that tip.
@normandymartinezluciano2810
@normandymartinezluciano2810 3 жыл бұрын
Thank you. That was a good explanation. I dit it by myself by entering the numbers of students and their names. I was successful doing it.
@paulmcwhorter
@paulmcwhorter 3 жыл бұрын
Excellent!
@maku5289
@maku5289 Жыл бұрын
Ouf already 19 classes done, what a ride! Thanks for sharing the knowledge.
@paulmcwhorter
@paulmcwhorter Жыл бұрын
Great job!
@TheScissorunner
@TheScissorunner Жыл бұрын
Started out great writing the first method and then struggled as I tried to add conditionals inside the () of the following methods. It worked but it was messy. Watched your explanation and when you created self.ng and self.grades I had an AH HA!! moment. It made sense to use these variable inside the other methods. Stopped the lesson, went back to my code and breezed through it. Lesson learned!! I AM LEGEND! Thank you!
@paulmcwhorter
@paulmcwhorter Жыл бұрын
Fantastic!
@husseinhamze2841
@husseinhamze2841 3 жыл бұрын
I'm learning arduino with you today 😂 u're really the best teacher ❤
@paulmcwhorter
@paulmcwhorter 3 жыл бұрын
Wow, thanks
@For_the-love_of_physics
@For_the-love_of_physics 3 жыл бұрын
Yes
@alfredcalleja450
@alfredcalleja450 Жыл бұрын
Paul, at the last tutorial, I folded like a cheap lawn chair from Kmart (we don't have Walmart here).....although Kmart sells some good stuff. I got the easy, Class parts right but folded on the Methods. I spent hours pulling out my hair, and that's no mean feat seeing I'm bald as a badger: I kept going round in circles. After many hours of crying and screaming I came to this tutorial and found out from you what I didn't understand. Thanks, this is such a great course and you're a real Huckleberry!
@paulmcwhorter
@paulmcwhorter Жыл бұрын
I remember Kmart as a child but thought they had gone out of business.
@alfredcalleja450
@alfredcalleja450 Жыл бұрын
@@paulmcwhorter Kmart is pretty strong here in Oz. 😀
@rubialugattimoreira1978
@rubialugattimoreira1978 2 жыл бұрын
Fantastic!
@MEB-qw7tp
@MEB-qw7tp 3 жыл бұрын
Hey Paul i love your teaching style
@paulmcwhorter
@paulmcwhorter 3 жыл бұрын
Glad you enjoy it!
@mikekeller7342
@mikekeller7342 3 жыл бұрын
I am legend! No cheap lawn chairs here! Thanks Paul!
@davidschnider1297
@davidschnider1297 Жыл бұрын
that WAS fun, Paul.... thank you for the introduction to Object Orientated Programming.,....I am looking forward to learning about Threads ....God bless, you sir...!
@paulmcwhorter
@paulmcwhorter Жыл бұрын
Glad it was helpful!
@joydeepp6521
@joydeepp6521 2 жыл бұрын
You are really the best
@KasunIshara
@KasunIshara 8 ай бұрын
Another great lesson.I wish I could find a java lesson series like this but still couldn't.
@fatmaahmedshany2073
@fatmaahmedshany2073 2 жыл бұрын
Thank you sir for the lesson 🙏
@hoggboss4204
@hoggboss4204 2 жыл бұрын
I AM LEGEND!!!! this one really stumped me, I feel a little like I cheated because I copy/pasted bits of other code into this one and kept changing the variables until I got it to work lol. but if it works it works and I'm happy.
@ottawakravmagaacademy7013
@ottawakravmagaacademy7013 3 жыл бұрын
I am legend, I really like how you explained classes.
@davidbuckley4912
@davidbuckley4912 Жыл бұрын
I am legend. Got it working without major problems
@amayaphotos8016
@amayaphotos8016 Жыл бұрын
I AM A LEGEND Loved this assignment Paul.
@paulmcwhorter
@paulmcwhorter Жыл бұрын
LEGEND!
@PhilipStanway
@PhilipStanway 9 ай бұрын
I am Legend... well I created an array of classes so spent hours on accessing the correct instance of class via the array ... but worth every second!
@masoudnateghi6251
@masoudnateghi6251 2 жыл бұрын
Hi Paul, args needs a tuple and we explicitly make a tuple when we write (1,) for instance. But when we write (1) it is simply two parenthesis.
@ricklawitzky8311
@ricklawitzky8311 Жыл бұрын
I AM LEGEND. Great video, I enjoy learning Python from you.
@paulmcwhorter
@paulmcwhorter Жыл бұрын
LEGEND!
@wendygrant2735
@wendygrant2735 2 жыл бұрын
Legend!👍
@RDKCREATIONS
@RDKCREATIONS 3 жыл бұрын
i did my home work by myself last week and it worked print("I AM A LEGEND")
@klmyself
@klmyself Жыл бұрын
I was able to do all but the High, Low, grades. Finally copied your code for that, but it gives first input grade for both low and high grades. Changing order of grade input still gives same results (90 for both high and low, or 93 for both if order in reverse) Code is the same, letter for letter.
@senpaizoro2592
@senpaizoro2592 Жыл бұрын
I'm Legend!!! that was tough but worth it
@mateobertin3376
@mateobertin3376 2 жыл бұрын
Hi Paul, I love your lessons. Greetings from Argentina! Also, I AM LEGEND
@paulmcwhorter
@paulmcwhorter 2 жыл бұрын
LEGEND!
@boydrogers7227
@boydrogers7227 3 жыл бұрын
Following an epic, two week battle between titan foes Legend and Lawnchair, when the dust settled, Legend stood--battered but victorious, and Lawnchair was nowhere to be found.
@paulmcwhorter
@paulmcwhorter 3 жыл бұрын
EXCELLENT!
@ousza
@ousza 3 жыл бұрын
Hi Paul, I just wanted to know what is your visual studio code color theme I have tried to find it but couldn't thank you in advance.
@jameskabongo676
@jameskabongo676 2 жыл бұрын
Proud to say I'm legend!
@igortomic1525
@igortomic1525 2 жыл бұрын
I am Legend :) Great lessons as always.
@paulmcwhorter
@paulmcwhorter 2 жыл бұрын
Legend!
@0Mr.Java0
@0Mr.Java0 Жыл бұрын
I am legend! Thanks Again.
@paulmcwhorter
@paulmcwhorter Жыл бұрын
LEGEND!
@LorenBurdette
@LorenBurdette Жыл бұрын
Great Lesson, again. I originally tried to enter a number of students and call the fn with students[i]=Students(). It was not having it.
@jabber2824
@jabber2824 12 күн бұрын
I am legend. In the end I used a list for the instance so it wasn’t hardcoded. You then have to loop through the list to find the right instance.i didn’t find a way to instantiate based on the content of a variable.
@flhTK-2012
@flhTK-2012 2 жыл бұрын
Well it looks like I get to do homework Again!
@danielsaenz5570
@danielsaenz5570 2 жыл бұрын
I am a lawn chair : | could not do the homework. Thanks for the great videos!!!
@user-qn1mh5oj9r
@user-qn1mh5oj9r 2 жыл бұрын
I AM A LEGEND ! Mr Paul I I made an empty array of students, asked for number of students and put all of them in the array with append function
@paulmcwhorter
@paulmcwhorter 2 жыл бұрын
Excellent
@berryblades
@berryblades Жыл бұрын
Blimey Paul, I struggled with Methods and Classes, I managed this but after multiple passes of your previous video lesson on it, I think I misunderstood the homework and spent a lot of time trying to figure out how to allow the user to select which student they wanted to add the grades for.....
@manuelaviles1534
@manuelaviles1534 Жыл бұрын
I was not able to do it, because i try to make something harder. I try to make students and input ther grades in the reminal, but i coudnt find a way to make the the student class in order to find the in the reminal. can that be done? to have a menue, where you can enter new students and apenthem in an array and then find the and get all ther info?
@woodpython8588
@woodpython8588 2 жыл бұрын
I'm a legend...Thanks a lot
@chalmerditmars7037
@chalmerditmars7037 Жыл бұрын
I over-thought this and was trying to create the first and last name inside the class instead of passing it in. I folded like a cheap Walmart Lawn chair. Then I watched a minute or two of the video up until you created names for student1 & 2 to pass in. I paused the video and went back and did the lesson, but I not only passed in the names but also the grades one at a time. It was not pretty. I used a lot of if statements and not many loops. I will now watch the rest of the video to see how to do it right.
@darryng
@darryng 2 жыл бұрын
Thank you! Please could you assist by helping me understand how you would go about having a user input x amount of students each with x amount of grades using classes and methods.
@soufianeerrami2507
@soufianeerrami2507 2 жыл бұрын
I tried to do the same but unfortunately I was blocked
@meJoKeR65
@meJoKeR65 3 жыл бұрын
Will you do advanced lessons?
@richardh568
@richardh568 Жыл бұрын
Hello all: Does anyone know how to disable that helper window? It's really annoying. Thanks
@cabdirisaqboos961
@cabdirisaqboos961 2 жыл бұрын
Is there a way that can generate objects automatically, in a while loop or sth, where while(1=1) and it asks the name of the student, then it assigns the name to object student[i] instead of defining them one by one and passing the arguments.
@bassman2162
@bassman2162 2 жыл бұрын
yes there is. That's how I did mine. Just ask for the num of students and num of grades then start your outer loop
@danielduplessis7221
@danielduplessis7221 2 жыл бұрын
I Am Legend!!!!
@harshpatel631
@harshpatel631 3 жыл бұрын
I did my homework and it was successful. Like you told us to say last lesson, "I am a legend".
@pedrosojunior
@pedrosojunior 8 ай бұрын
I am a Legend!!
@paulmcwhorter
@paulmcwhorter 8 ай бұрын
LEGEND!
@kanishkar9897
@kanishkar9897 23 күн бұрын
I am Legend!
@soufianeerrami2507
@soufianeerrami2507 2 жыл бұрын
I am a LEGEND
@wayneswan3092
@wayneswan3092 2 жыл бұрын
Ok, I know where I'm having trouble with classes. I understand the structure as it applies to the "example" given, I understand what part references to what other part of the structure, but I can't grasp how to apply a new application to the class structure when I go off and try to build my own using a totally different library.. Does that make sense? Like I tried to figure out how to build a class structure to add FPS in my video, and I was completely lost after building the function and object, as to how to apply it further. I feel like I really need to stay here for a bit and work on getting this down. Can you give me a semi-simple library to build a class from? I feel like I could build classes that find names, GPA's, salaries, employees, etc, all week long, but when it comes to utilizing a library, That's when I fold. Maybe I'll look through your python for beginners videos a little closer. I haven't followed this series yet. Just referenced to it for more examples.
@paulmcwhorter
@paulmcwhorter 2 жыл бұрын
Maybe part of it is not all problems are suited for classes. I would not do fps with a class, because it is not suited for it. If I had a tool box full of tools, I could create a tool class where I could have name of tool, cost, function etc. Not every problem you solve with a class
@petefontana1958
@petefontana1958 2 жыл бұрын
I am legend but I demand nothing less than that of myself. My 11 years of retirement has almost wiped out my 30+ years of programming experiance. I will not give up. I just got my Raspberry Pi and will be starting those lessons in a couple of days along with continuing VPython.
@paulmcwhorter
@paulmcwhorter 2 жыл бұрын
Great! Keep it up.
@mannatkaur1146
@mannatkaur1146 3 жыл бұрын
I AM LEGEND!
@HarshCreatives
@HarshCreatives 2 жыл бұрын
I am a Legend
@ritwikkaushik4026
@ritwikkaushik4026 3 жыл бұрын
i M partial Legend!!
@elyeslaalai1062
@elyeslaalai1062 2 жыл бұрын
I'm legend!!
@paulmcwhorter
@paulmcwhorter 2 жыл бұрын
Yes you are!
@noweare1
@noweare1 2 жыл бұрын
Didn't know that once a self.x is defined the other methods and even your main program knows about it.
@mannatkaur1146
@mannatkaur1146 3 жыл бұрын
I had a doubt from the code. Why is that you wrote this in the code self.ng = ng
@NhanNguyen-sg9iu
@NhanNguyen-sg9iu 2 жыл бұрын
I am LEGEND. =)))))
@philluvschips3787
@philluvschips3787 4 ай бұрын
I am legend, only trouble I had was trying to assign the grades to an array or list to figure hi low so has to 'if' all 5 grades 1 at a time
@philluvschips3787
@philluvschips3787 4 ай бұрын
Rookie error floating when I should be inting! So I put everyone's grades in at the same time and then print everyone together at the same time - everyone has the same grades as the last input, no 'self' to be seen anywhere, but I have self'd everything? so is it method action, method action every time?
@charlotteswift
@charlotteswift 2 жыл бұрын
My previous comment was after doing the homework but before watching this tutorial but now I've watched it. I know you were doing it on the fly, but why did you repeat all the code for the grade report for both students instead of adding printGradeReport to the class. Also I feel that the class should have been 'student' rather than 'students' because when you are creating student1 he/she is a student rather than a students. 'Students' would be an array of students.Does it matter anyway?
@andylaurie326
@andylaurie326 2 жыл бұрын
One thing you have not shown us is how to write a program so the USER can enter the student first and last names. How do we program so additional objects can be added or subtracted by the USER ? Does anyone out there have an idea.?
@krishnendumaity4480
@krishnendumaity4480 2 жыл бұрын
nos=int(input('How many students do you have in total? ')) students=[] for i in range(nos): f=input('Enter first name: ') l=input('Enter last name: ') student(f,l) students.append(student(f,l)) print(students) for i in students: i.inputGrades()
@andylaurie326
@andylaurie326 2 жыл бұрын
@@krishnendumaity4480 thank you for the reply. I wonder how this can be used in a class so the student objects can be entered along with each students attributes.?
@EFoxVN
@EFoxVN 2 жыл бұрын
Yeah, I'll say it upfront: "I folded up like a cheap Walmart lawn chair". Singing it on the tune of one of ABBA's latest songs "No doubt about it". I can also say that I spent at least 2 hours on trying to do it on my own, if not more. So yeah, sometimes we fail. This time I did. Edit: I was on the right track, but seemingly forgot to use array.append(x) function, hence I kept getting errors. Real rookie mistake it seems!
@paulmcwhorter
@paulmcwhorter 2 жыл бұрын
There are three types of people in the world . . . Those who try and succeed, those who try and fold up like a cheap walmart lawnchair, and then the third . . . those timid souls who never even enter the arena. Much better to try and fold than to never had tried. Remember the famous quote of Teddy Roosevelt. “It is not the critic who counts: not the man who points out how the strong man stumbles or where the doer of deeds could have done better. The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood, who strives valiantly, who errs and comes up short again and again, because there is no effort without error or shortcoming, but who knows the great enthusiasms, the great devotions, who spends himself in a worthy cause; who, at the best, knows, in the end, the triumph of high achievement, and who, at the worst, if he fails, at least he fails while daring greatly, so that his place shall never be with those cold and timid souls who knew neither victory nor defeat.”
@richardbutt8258
@richardbutt8258 2 жыл бұрын
Yeah, I was getting annoyed with the popup myself. Fortunately, I found instructions for disabling it.
@arnaudmasse7839
@arnaudmasse7839 Жыл бұрын
I AM LEGEND !!
@paulmcwhorter
@paulmcwhorter Жыл бұрын
LEGEND!
@wishicouldarduino8880
@wishicouldarduino8880 3 жыл бұрын
Are you on the nano?😁👍🤖🛸
@TheSudouser
@TheSudouser Жыл бұрын
Gave it my best shot but folded like a cheap wal-mart lawn chair halfway through
@86Carrera911
@86Carrera911 2 жыл бұрын
I am legend.
@gordonspond
@gordonspond 2 жыл бұрын
私は伝説です
@polito-yd8fp
@polito-yd8fp 9 ай бұрын
I am Legend 😊
@jaime5199
@jaime5199 2 жыл бұрын
On this one I was a legendary lawnchair or a cheap legend.
@luisdematos7154
@luisdematos7154 2 жыл бұрын
I am legend...
@hamishgrant2802
@hamishgrant2802 2 жыл бұрын
i am legend
@silver5970
@silver5970 3 жыл бұрын
I made it but i used two function that wasn't in class.
@ibrahimsaad9299
@ibrahimsaad9299 3 жыл бұрын
Hello Mr Paul how are you I am Ibrahim Saad from Libya I was student at mosrta training center at steel company in 1993 to 1995 I was instrumentation student how can l learn more about the electronics how can I reber new types of circuit board whether small chepes and thank you viry much .
@paulmcwhorter
@paulmcwhorter 3 жыл бұрын
Libya, wow, how cool is that? Welcome to the channel. Check out my arduino lessons. Lots of circuits in those lessons
@ibrahimsaad9299
@ibrahimsaad9299 3 жыл бұрын
@@paulmcwhorter thank you viry much
@alycapolo7376
@alycapolo7376 3 жыл бұрын
Hey buddy the lesson are good but as you move on am starting getting confused
@Godsbeloved05
@Godsbeloved05 2 жыл бұрын
I am legend
@dashakarataj6047
@dashakarataj6047 11 ай бұрын
Hello sir . I hope this message finds you well ! . Thanks a lot for this great tutorial , i have some doubts actually regarding this lesson , i have been trying to write a code for this task for a week , but seems that there are some mistakes that i couldn't find , so can you check it please ???, waiting for your feedback! class students: def __init__(self,x,y): self.firstname=x self.lastname=y def grade(self,z): self.grades=[] self.z=z for i in range(0,z,1): grd=float(input("please enter" +x+"'s grade: ")) self.grades.append(grd) return self.grades def prit(self): print(self.firstname,self.lastname,"'s grades are: ") print(self.grades) def average(self): sum=0 for i in range(0,self.z,1): sum=sum+self.grades[i] avg=float(sum/self.z) self.avg=avg def LH (self): lowgrade=100 highgrade=0 for i in range(0,self.z,1): if(self.grades[i]highgrade): highgrade=self.grades[i] self.high=self.grades[i] x=input('What is the name of the student ?: ') y=input("what is "+x+"'s last name?: ") z=int(input("how many grades does "+x+" have?: " )) student1=students(x,y) o=input('If taht is all please enter - or if you need to add more info about another student please enter + ?: ') if(o=='+'): x=input('What is the name of the student ?: ') y=input("what is "+x+"'s last name?: ") z=int(input("how many grades does "+x+" have?: " )) student2=students(x,y) else: print('okay!') w=input('which student would you like to check? , please enter the number of the student (1 or 2): ') if (w=='1'): student1.grade(z) A=input("we created a list of the student's grades , would you like to see it ?: ") if(A=='yes' or A=='YES'): print(student1.prit()) else: print('okay!') v=input("would you like to see the grades's average?: ") if(v=='YES'and v=='yes'): print('the avergae is: ',student1.average()) else: print('okay!') HL=input("would you like to see the highest and lowest grades of the student?: ") if(HL=='Yes'and HL=='YES'): print('the lowest grade is: ',student1.LH()) else: print('that is all, thank you ') else: student2.grade(z) A=input("we created a list of the student's grades , would you like to see it ?: ") if(A=='yes' or A=='YES'): print(student2.prit()) else: print('okay!') v=input("would you like to see the grades's average?: ") if(v=='YES'and v=='yes'): print('the avergae is: ',student2.average()) else: print('okay!') HL=input("would you like to see the highest and lowest grades of the student?: ") if(HL=='Yes'and HL=='YES'): print('the lowest grade is: ',student2.LH()) print('') print('that is all , thank you')
@Leonarco333
@Leonarco333 2 жыл бұрын
I’m at 90 lines and stuck. I’m positive I’m overthinking this. Edit: oh yeah. I was trying to ask for the students and write them to objects rather than code in a roster