23.4 LAB: Student class (Use Python) In main.py define the Student class that has two attributes: name and gpa Implement the following instance methods: A constructor that sets name to "Louie" and gpa to 1.0 set_name(self, name) - set student's name to parameter name get_name(self) - return student's name set_gpa(self, gpa) - set student's gpa to parameter gpa get_gpa(self) - return student's gpa Ex. If a new Student object is created, the default output is: Louie/1.0 Ex. If the student's name is set to "Felix" and the gpa is set to 3.7, the output becomes: Felix/3.7
OOPs
In today's technology-driven world, computer programming skills are in high demand. The object-oriented programming (OOP) approach is very much useful while designing and maintaining software programs. Object-oriented programming (OOP) is a basic programming paradigm that almost every developer has used at some stage in their career.
Constructor
The easiest way to think of a constructor in object-oriented programming (OOP) languages is:
23.4 LAB: Student class (Use Python)
In main.py define the Student class that has two attributes: name and gpa
Implement the following instance methods:
- A constructor that sets name to "Louie" and gpa to 1.0
- set_name(self, name) - set student's name to parameter name
- get_name(self) - return student's name
- set_gpa(self, gpa) - set student's gpa to parameter gpa
- get_gpa(self) - return student's gpa
Ex. If a new Student object is created, the default output is:
Louie/1.0
Ex. If the student's name is set to "Felix" and the gpa is set to 3.7, the output becomes:
Felix/3.7
![LAB
23.4.1: LAB: Student class
0/ 10
ACTIVITY
main.py
Load default template..
1 class Student:
2
# Type your code here
4 if
main_":
name_
initial_student = Student()
print (initial_student.get_name (),'/', initial_student.get_gpa())
==
5
6
initial_student.set_name('Felix')
initial_student.set_gpa(3.7)
print(initial_student.get_name(), 7', initial_student.get_gpa(OI
8
9
10
Run your program as often as you'd like, before submitting for grading. Below, type any needed
input values in the first box, then click Run program and observe the program's output in the
Develop mode
Submit mode
second box.
Enter program input (optional)](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fa1941e1f-25fd-43e5-9f03-eae8cd1d036f%2Fde778f37-9909-4f5b-a212-5b668541e703%2Fn6qx96_processed.png&w=3840&q=75)
![](/static/compass_v2/shared-icons/check-mark.png)
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)