1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
masha68 [24]
3 years ago
12

Write a class Student() such that it has an attribute 'score' (that is initialized with 10) and three methods: add_score(): adds

10 to the score decrease_score(): decreases score by 10 __str__(): returns the current score (should return a string) Example:

Computers and Technology
1 answer:
Feliz [49]3 years ago
7 0

Answer:

I am writing the Python program. Let me know if you want the program in some other programming language. Here is the Python code:

class Student(object):

   def __init__(a,score=10):

       a.score=score

   def add_score(a,score):

       a.score += 10

       return (score)

   def decrease_score(a,score):

       a.score -=10

       return (score)

   def __str__(a):

       current_score="{}".format(a.score)

       return current_score

Explanation:

The program has a Student() class with attribute score.

It has the following methods:

__init__(): This method works as a constructor and enables to initialize score attribute of Student class. The value of score is initialized to 10. I have used a as the instance of Student class. However self keyword can also be used as an instance of the object to access the attributes and methods of Student class.

add_score() This method is used to add 10 to the score.

decrease_score() This method is used to decrease the score by 10.

__str__() This method is used to return the current score. format() is used here to return a string. current_score holds the value of the current score.

If you want the check the working of the program, then you can use the following statements to see the results on the output screen:

p = Student()

print(p)

p.add_score(p)

print(p)

This will create an object p of Student class and calls the above methods to display the values of the score according to the methods.

The program along with its output is attached.

You might be interested in
Traffic collisions are among the top killers of children in America.
Blababa [14]
Whats the question if its true or false, then true
8 0
3 years ago
A technician is tasked with installing the Windows OS on a Mac OS computer so that the computer can boot to either the Mac OS or
nata0808 [166]

Answer:

Key chain because it easier

Explanation:

4 0
2 years ago
Which of the following words, if it replaced the word "enthusiasts" in the sentence above, would CHANGE the meaning of the sente
Sonja [21]

Answer:

I would need the sentence to make sure that I am correct but I am pretty sure it is C. aficionados

Explanation:

7 0
3 years ago
Sarah is delivering a presentation on the solar system. Each slide consists of not more than four to five points. However, she n
slava [35]

Answer:

Handouts

Explanation:

Handouts is the section where the audience can have a more detailed grasp on the points presented in the slide for more in dept information about the presentation.

5 0
3 years ago
Charli D'amelio bought her followers. <br><br> True or true? ;)​
tatuchka [14]

Answer:

I Think its true

Explanation:

because it's TRUE

7 0
4 years ago
Read 2 more answers
Other questions:
  • Identify the publisher in this citation:Carter,Alan.A guide to Entrepreneurship.New York: River’2008.Print.
    9·1 answer
  • When you right-click a spreadsheet object, what command should you select to activate the sheet?
    6·2 answers
  • Rob Janoff believes that technology should not be used too
    11·1 answer
  • A user is troubleshooting a mobile device app that is displaying errors and has contacted the app manufacturer’s technical suppo
    14·1 answer
  • What is the unemployment rate if the GDP gap is 13.5%?<br><br> A. 6.25%<br> B. 6.75%<br> C. 6.7%
    8·1 answer
  • Complete the statement below using the correct term.
    14·1 answer
  • Each pixel includes 3 colors; Red, Green and Blue. Each color uses 8 bits to store it's intensity. How many Bytes are needed for
    12·1 answer
  • Difference between second and third generation of computer<br>​
    14·1 answer
  • The operation of an enable input on a multiplexer chip is.
    14·1 answer
  • Write an if-else statement that determines whether the variable points is outside the range of 9 to 51. If points is outside the
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!