answer.
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]
1 year 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]1 year 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
Which statement is correct? a. choice of metric will influence the shape of the clusters b. choice of initial centroids will inf
katrin2010 [14]

Answer: the answer is c

Explanation:in general, the merges and splits in hierarchical clustering are determined in a greedy manner

8 0
2 years ago
As the network administrator for a growing company, you’re asked to solve a remote access dilemma. The 12 employees who work fro
Strike441 [17]

Answer:

To provide remote network access to the users to work, the network administrator can use virtual private network (VPN) along with some firewall to protect the system from hackers and other security threats.

Explanation:

Virtual Private Network (VPN) can be used to provide remote access to the users who are currently working from some remote areas. Many companies who have their branches or franchises in different parts of the city uses VPN to connect then all with the company server.

In this way, a firewall has been needed that protect the systems of users as well as company to protect from different security hazards such as hackers, authorization of the users and other security threats.

in this case, 12 em[employees who need remote access to the network can be connected through VPN along with the installation of some suitable firewall.

8 0
2 years ago
Alison is having a hard time at work because her Inbox is flooded with emails every day. Some of these emails are unsolicited. S
fredd [130]

Answer:

1.c 2.a

Explanation:

If the new emails she doesn't need could be ignored in spam. the old ones are useless so trash em.

5 0
2 years ago
Read 2 more answers
#In Pokemon Go, a Pokemon is defined by several different #parameters. For simplicity in this problem, we'll say that #every Pok
Semenov [28]

Answer:

YUP

Explanation:

5 0
2 years ago
Read 2 more answers
This program will calculate the rise in ocean levels over 5, 10, and 50 years, Part of the program has been written for you. The
GREYUIT [131]

Answer:

Here is the C++ program:

#include <iostream>  //to use input output functions

using namespace std;  //to identify objects cin cout

int main(){  //start of main method

     

   double risingLevel;  //declares a double type variable to hold rising level

   cin>>risingLevel;  //reads the value of risingLevel from user

   

   cout<<"Level: "<<risingLevel<<endl;  //displays the rising level

   cout << "Years: 5, Rise: " << risingLevel * 5<<endl;  //displays the rise in ocean level over 5 years

   cout << "Years: 10, Rise: " << risingLevel * 10<<endl;  //displays the rise in ocean level over 10 years

   cout << "Years: 50, Rise: " << risingLevel * 50<<endl;  //displays the rise in ocean level over 50 years

}

Explanation:

The program works as follows:

Lets say the user enters rising level 2.1 then,

risingLevel = 2.1

Now the first print (cout) statement :

cout<<"Level: "<<risingLevel<<endl;  prints the value of risingLevel on output screen. So this statement displays:

Level: 2.1          

Next, the program control moves to the statement:

   cout << "Years: 5, Rise: " << risingLevel * 5<<endl;

which computes the rise in ocean levels over 5 years by formula:

risingLevel * 5 = 2.1 * 5 = 10.5

It then displays the computed value on output screen. So this statement displays:

Years: 5, Rise: 10.5                                                                                                                          Next, the program control moves to the statement:

   cout << "Years: 10, Rise: " << risingLevel * 10<<endl;

which computes the rise in ocean levels over 10 years by formula:

risingLevel * 10 = 2.1 * 10 = 21

It then displays the computed value on output screen. So this statement displays:

Years: 10, Rise: 21                                                                                      

Next, the program control moves to the statement:

   cout << "Years: 50, Rise: " << risingLevel * 50<<endl;

which computes the rise in ocean levels over 50 years by formula:

risingLevel * 50 = 2.1 * 50 = 105

It then displays the computed value on output screen. So this statement displays:

Years: 50, Rise: 105                                                                                                                          Hence the output of the entire program is:

Level: 2.1                                                                                                                     Years: 5, Rise: 10.5                                                                                                           Years: 10, Rise: 21                                                                                                            Years: 50, Rise: 105

The screenshot of the program and its output is attached.

4 0
2 years ago
Other questions:
  • Frequency of failure and network recovery time after a failure are measures of the _______ of a network.
    11·1 answer
  • The final step of the DHCP Discovery process is known as ______.
    5·1 answer
  • #A year is considered a leap year if it abides by the #following rules: # # - Every 4th year IS a leap year, EXCEPT... # - Every
    5·1 answer
  • Suppose the information content of a packet is the bit pattern 1110 0110 1001 1101 and an even parity scheme is being used. What
    15·1 answer
  • A key field is used to _____. enter a password uniquely identify records merge data list the most important information
    12·2 answers
  • Assign decoded_tweet with user_tweet, replacing any occurrence of 'TTYL' with 'talk to you later'. Sample output with input: 'Go
    14·2 answers
  • How many times does the following loop execute?int upperCaseLetters = 0;String str = "abcdEfghI";boolean found = false;for (int
    5·1 answer
  • Print either "Fruit", "Drink", or "Unknown" (followed by a newline) depending on the value of userItem. Print "Unknown" (followe
    13·1 answer
  • Initialize the list short_names with strings 'Gus', 'Bob', and 'Zoe'. Sample output for the given program:
    9·1 answer
  • A program is divided into 3 blocks that are being compiled on 3 parallel computers. Each block takes an Exponential amount of ti
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!