Question

PYTHON Create a Student class and initialize it with name and roll number. Make methods to...

PYTHON

Create a Student class and initialize it with name and roll number. Make methods to :
1. Display - It should display all informations of the student.
2. setAge - It should assign age to student
3. setMarks - It should assign marks to the student.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Hi,

Please find the answer for your question above.

Student.py:

class Student():
def __init__(self,name,roll):
self.name = name
self.roll= roll
def display(self):
print self.name
print self.roll
def setAge(self,age):
self.age=age
def setMarks(self,marks):
self.marks = marks

Hope this clears your query.

Add a comment
Know the answer?
Add Answer to:
PYTHON Create a Student class and initialize it with name and roll number. Make methods to...
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. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • PYTHON*************** Create a Person Class that: Accepts First Name, Last Name, Age, and Gender Has a...

    PYTHON*************** Create a Person Class that: Accepts First Name, Last Name, Age, and Gender Has a method that adds all persons Validate all input, not left empty for First Name, Last Name, Gender and numeric for age and throw an exception if it does not validate within the class. Create a Student Class that: Inherits the Person Class Accepts GPA Validate GPA (>= 0 and <= 4.0) and throw exception if it does not validate within the class. Has methods...

  • Graded Exercise Create a class named Student. A Student has fields for an ID number, number...

    Graded Exercise Create a class named Student. A Student has fields for an ID number, number of credit hours earned, and number of points earned. (For example, many schools compute grade point averages based on a scale of 4, so a three-credit-hour class in which a student earns an A is worth 12 points.) Include methods to assign values to all fields. A Student also has a field for grade point average. Include a method to compute the grade point...

  • Write a Python class, Circle, constructed by a radius and two methods which will compute the...

    Write a Python class, Circle, constructed by a radius and two methods which will compute the area and the perimeter of a circle. Include the constructor and other required methods to set and get class attributes. Create instances of Circle and test all the associated methods. Write a Python class, Rectangle, constructed by length and width and a method which will compute the area of a rectangle. Include the constructor and other required methods to set and get class attributes....

  • In python Create a class that holds personal data: name, address, age, and phone number. Write...

    In python Create a class that holds personal data: name, address, age, and phone number. Write the necessary get (accessor) and set mutator methods. Also include a program that creates three instances of the class. This could be you and 2 friends or 2 family members.

  • Must be in Python 3 exercise_2.py # Define the Student class class Student():    # Ini...

    Must be in Python 3 exercise_2.py # Define the Student class class Student():    # Initialize the object properties def __init__(self, id, name, mark): # TODO # Print the object as an string def __str__(self): return ' - {}, {}, {}'.format(self.id, self.name, self.mark) # Check if the mark of the input student is greater than the student object # The output is either True or False def is_greater_than(self, another_student): # TODO # Sort the student_list # The output is the sorted...

  • a) Create an abstract class Student. The class contains fields for student Id number, name, and...

    a) Create an abstract class Student. The class contains fields for student Id number, name, and tuition. Includes a constructor that requires parameters for the ID number and name. Include get and set method for each field; setTuition() method is abstract. b) The Student class should throw an exception named InvalidNameException when it receives an invalid student name (student name is invalid if it contains digits). c) Create three student subclasses named UndergradStudent, GradeStudent, and StudentAtLarge, each with a unique...

  • python code? 1. Create a class called Person that has 4 attributes, the name, the age,...

    python code? 1. Create a class called Person that has 4 attributes, the name, the age, the weight and the height [5 points] 2. Write 3 methods for this class with the following specifications. a. A constructor for the class which initializes the attributes [2.5 points] b. Displays information about the Person (attributes) [2.5 points] c. Takes a parameter Xage and returns true if the age of the person is older than Xage, false otherwise [5 points] 3. Create another...

  • Class DemoArray: 1. Create an array of type String , name it words, and initialize it...

    Class DemoArray: 1. Create an array of type String , name it words, and initialize it with the following words: one, two, three, four, five, four, three, two, one 2. Use a method of class Arrays to print the array. Make sure to use a label 3. At this point we are going to fix the misspelled word three. Use a loop to access the elements of the array. One by one check whether the current element happens to be...

  • Create the Python code for a program adhering to the following specifications. Write an Employee class...

    Create the Python code for a program adhering to the following specifications. Write an Employee class that keeps data attributes for the following pieces of information: - Employee Name (a string) - Employee Number (a string) Make sure to create all the accessor, mutator, and __str__ methods for the object. Next, write a class named ProductionWorker that is a subclass of the Employee class. The ProductionWorker class should keep data attributes for the following information: - Shift number (an integer,...

  • Create a Business class: Instance variables: Student id 1000 - 9999 Student name Present Student email...

    Create a Business class: Instance variables: Student id 1000 - 9999 Student name Present Student email address Present Number of hours 3.5 - 18 Two constructors should be coded, one that accepts no arguments and sets every field to its default value, and one that accepts all four fields, and assigns the passed values into the instance variables. For each instance variable create two methods; a getter and a setter. Add a static method to the class that will accept...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT