Question

write code using python or repl.it 1. List 4 attributes that you'd create for class "student"....

write code using python or repl.it
1. List 4 attributes that you'd create for class "student".
2. List 2 setters and 2 getters for class student including their parameters
3. Write the complete definition for class student including attributes and methods created above using the correct Python syntax.
4. Create one object of class student and print the values of all its attributes. You can either call the getter method or access the attribute directly using the dot notation.

Homework Answers

Answer #1

Have a look at the below code. I have put comments wherever required for better understanding.

# create Student class
class Student:
  # create the constructor
  def __init__(self,name,id,age,gender):
    self.name = name 
    self.id = id 
    self.age = age 
    self.gender  = gender 
  # Getters
  def getName(self):
    return self.name 

  def getAge(self):
    return self.age 
  # Setters
  def setId(self,id):
    self.id = id 

  def setGender(self,gender):
    self.gender = gender


# create an object of class student
student = Student('Alexa',1,23,'Female')
# print all the attributes
print(student.getName())
print(student.getAge())
print(student.id)
print(student.gender)

  

  

  

Happy Learning!

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Write the following problem in Java Create a class Dog, add name, breed, age, color as...
Write the following problem in Java Create a class Dog, add name, breed, age, color as the attributes. You need to choose the right types for those attributes. Create a constructor that requires no arguments. In this constructor, initialize name, breed, age, and color as you wish. Define a getter and a setter for each attribute. Define a method toString to return a String type, the returned string should have this information: “Hi, my name is Lucky. I am a...
Write Python code to define a class called Student. The Student class should have the following...
Write Python code to define a class called Student. The Student class should have the following private fields: name – to store the name of a student attend – to store how many times a student attend the class grades – a list of all student’s grades The Student class should have the following methods: a constructor getter method for the name field attendClass method: that increments the attend field (should be called every time a student attends the class)....
1. let us create a python class called Star(). Write Star() such that an instance (s1)...
1. let us create a python class called Star(). Write Star() such that an instance (s1) of a star is created with the call s1=Star(…) where the calling parameters of Star() define all the information of the star, including, at least, name, distance, surface temperature and radius. Look these up for your favorite star and run a main that proves it works. 2. Next, create a second class called Information(). It will have zero calling parameters and just one item...
Challenge: Animal Class Description: Create a class in Python 3 named Animal that has specified attributes...
Challenge: Animal Class Description: Create a class in Python 3 named Animal that has specified attributes and methods. Purpose: The purpose of this challenge is to provide experience creating a class and working with OO concepts in Python 3. Requirements: Write a class in Python 3 named Animal that has the following attributes and methods and is saved in the file Animal.py. Attributes __animal_type is a hidden attribute used to indicate the animal’s type. For example: gecko, walrus, tiger, etc....
1.let us create a python class called Star(). Write Star() such that an instance (s1) of...
1.let us create a python class called Star(). Write Star() such that an instance (s1) of a star is created with the call s1=Star(…) where the calling parameters of Star() define all the information of the star, including, at least, name, distance, surface temperature and radius. Look these up for your favorite star and run a main that proves it works. 2. Next, create a second class called Information(). It will have zero calling parameters and just one item to...
JAVA Learning Objectives: To be able to code a class structure with appropriate attributes and methods....
JAVA Learning Objectives: To be able to code a class structure with appropriate attributes and methods. To demonstrate the concept of inheritance. To be able to create different objects and use both default and overloaded constructors. Practice using encapsulation (setters and getters) and the toString method. Create a set of classes for various types of video content (TvShows, Movies, MiniSeries). Write a super or parent class that contains common attributes and subclasses with unique attributes for each class. Make sure...
**Python** Write code that will: Create a list using the following integers: 58, 98, 82, 69,...
**Python** Write code that will: Create a list using the following integers: 58, 98, 82, 69, 90, 74, 68, 88, 71, 44 Sort the list numerically from smallest to largest Iterate through the list that converts from a numerical grade (1-100) to a letter grade (A, B, C, D, F) and print the applicable grade to the console window, but preface each answer with “Your grade is : “ before the letter grade
We encourage you to work in pairs for this challenge to create a Student class with...
We encourage you to work in pairs for this challenge to create a Student class with constructors. First, brainstorm in pairs to do the Object-Oriented Design for a Student class. What data should we store about Students? Come up with at least 4 different instance variables. What are the data types for the instance variables? Write a Student class below that has your 4 instance variables and write at least 3 different constructors: one that has no parameters and initializes...
Part 1 - LIST Create an unsorted LIST class ( You should already have this code...
Part 1 - LIST Create an unsorted LIST class ( You should already have this code from a prior assignment ). Each list should be able to store 100 names. Part 2 - Create a Class ArrayListClass It will contain an array of 27 "list" classes. Next, create a Class in which is composed a array of 27 list classes. Ignore index 0... Indexes 1...26 correspond to the first letter of a Last name. Again - ignore index 0. index...
Write python code for the queue class buuilt with a linked list using: First- returns first...
Write python code for the queue class buuilt with a linked list using: First- returns first value in queue, PrintQ-returns whole queue as list, RemoveValue-removes specific value from queue, RemoveIndex-removes value from queue by index
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT