Implement a class named Rectangle. The class should contain:
1. Two data attributes of type float named width and height that specify the width and the height of the rectangle.
2. A constructor that creates a rectangle with the specified width and height. If no argument is provided, it should use 1.0 for both values. If any input value is negative, the function should raise an exception.
3. Functions get_width and get_height that return the corresponding value
4. The set_width and set_height function that update the values if and only if the input is positive; otherwise do nothing
5. Functions get_area and get_perimeter that return the area and the perimeter of this rectangle respectively.
6. A function rotate that swaps the height and width of a rectangle object.
7. A class variable count that keeps track of the number of rectangles created so far.
8. A class method get_count that returns the above value.
9. An equality operator that returns True if and only if the two rectangles are of the same shape.
10. A __str__ function that returns the information of this rectangle in some readable format.

Answers

Answer 1

Answer:

Explanation:

The following code is written in Python and creates a Rectangle class that performs all the necessary functions mentioned in the question...

from itertools import count

class Rectangle():

   _ids = count(0)

   width = 1.0

   height = 1.0

   def __init__(self, width, height):

       if (width < 0) or (height < 0):

           raise Exception("Sorry, no numbers below zero")

       else:

           self.id = next(self._ids)

           self.width = width

           self.height = height

   def get_width(self):

       return self.width

   def get_height(self):

       return self.height

   def set_width(self, width):

       if width > 0:

           self.width = width

   def set_height(self, height):

       if height > 0:

           self.height = height

   def get_area(self):

       return (self.height * self.width)

   def get_perimeter(self):

       return ((self.height * 2) + (self.width * 2))

   def rotate(self):

       temp = self.height

       self.height = self.width

       self.width = temp

   def get_count(self):

       return self._ids

   def equality(self, rectangle1, rectangle2):

       if rectangle1 == rectangle2:

           return True

       else:

           return False

   def __str__(self):

       return 'Rectangle Object with Height: ' + str(self.height) + ' and Width: ' + str(self.width)


Related Questions

what is digital museum​

Answers

Access hundreds of professional development resources for museum professionals. Museum professionals can benefit at any career stage from student to retiree. Student Membership. Industry Membership. Established Since 1906. Museum Memebership. 501(c)3 Nonprofit Org.

Explanation:

1.Digital museum is a museum exhibition platform that utilizes computer and information technology, on which cultural relics and historical collections can be preserved and displayed in digital format. It is one of the main outcomes of digital curation. Learn more in: The Challenges of Digital Museum

how does abstraction help us write programs

Answers

Answer:

Abstraction refines concepts to their core values, stripping away ideas to the fundamentals of the abstract idea. It leaves the common details of an idea. Abstractions make it easier to understand code because it concentrates on core features/actions and not on the small details.

This is only to be used for studying purposes.

Hope it helps!

A slide titled Alexander Graham Bell. There are 6 bulleted entries on the slide, and there is a lot of text on the slide. There is very little space around the text to the edges of the slide. There is no image on the slide and the text is shaded white on a blue background.
This slide has several design problems, according to the design principles that were just reviewed. What are the problems? Check all that apply.

The slide contains too much text.
The slide does not have an image or visual aid.
The text is too small.
The background makes it hard to read the text.
The slide does not have enough empty space.

Answers

Answer:

The following are design problems associated with the Alexander Graham Bell slide:

The slide contains too much text.

The slide does not have an image or visual aid.

The background makes it hard to read the text.

The slide does not have enough empty space.

Explanation:

Answer:

It's not ABDE, it's ABE

Explanation:

i tried it

What are folders within folders called​

Answers

it is called a subfolder????

Answer:

The folder within folder are also know as subfolder .

The IBM system/370 architecture uses a two-level memory structure and refers to the two levels as segments and pages, although the segmentation approach lacks many of the features described in Chapter 8. For the basic 370 architecture, the page size may be either 2 KB or 4 KB, and the segment size is fixed at either 64 KB or 1 MB. For the 370/XA and 370/ESA architectures, the page size is 4 KB and the segment size is 1 MB. What advantages of segmentation does this scheme lack

Answers

Answer:

Explanation:

Introductory thought:  

Thinking about the architecture for the IBM System/370 that is fit for giving higher preparing force and more stockpiling limit since it utilizes two-level of memory structure which is known as the segments and caches and the given plan is as per the following:  

In division the address space is isolated into quantities of segments of variable sizes and then again in paging the address space is partitioned into quantities of fixed-sized units that are known as pages.It is more helpful for better utilization of memory. The fundamental architecture for the IBM system/370 architecture the size of the page are for the most part either 2KiloBytes (KB) or 4KB and the size of the segments will be changed from 64KiloBytes to 1MegaBytes.   The two dissimilar kinds of architecture that existed are 370/XA that is the Extended Architecture, also the other is 370/ESA known as the Enterprise Systems Architecture.    The page size is 4KB for the Extended variant and 1MB for the Enterprise Systems Architecture (ESA).

Advantages of segmentation that the given scheme needs to incorporate includes:

In the configuration of the architecture for IBM System/370 the segments are of a fixed size which isn't noticeable for the programmer and as such he will know the interior subtleties and subsequently inside architecture is stowed away from outside gentle.  In IBM system/370 the reference bit is zero for the processor hardware as well as at whatever point another page is stacked into the edge, the reference bit is changed to one after referring to a specific area inside the casing.  The quantity of lines of the page outline table is overseen by the Operating System and a page outline table section is moved to start with one line then onto the next depending on the length of the span of the referenced bit from the page outline which is sets to nothing. Whenever there is a need to supplant the page then the page browsed the line of the longest life non referenced edges.

What type of role does the group leader have? Informal negative positive Formal

Answers

Just as leaders have been long studied as a part of group communication research, so too have group member roles. Group roles are more dynamic than leadership roles in that a role can be formal or informal and played by more than one group member

A set of object that share a common structure and common behavior in database is called ​

Answers

An Object Class. Hopefully this answer is right.

What is your favorite anime ( All movies and episodes related to them count )

A. Seven Deadly Sins
B. Naruto
C. Dragon Ball
D. One piece
C. The misfit of the demon king academy
E. Classroom of the Elite

Answers

Answer:

B. Naruto

Explanation:

Dragon ball, first saw it as a child and have been fan since


Blocks that allows you to repeat scripts multiple times are

Answers

Answer:

here are several methods to make a script perform an action for a set amount of ... Technically, this may not work if you have wait blocks or other blocks that take up time. ... This script uses the timer and the Repeat Until block.

Explanation:

Write a full class definition for a class named GasTank , and containing the following members:
A data member named amount of type double.
A constructor that no parameters. The constructor initializes the data member amount to 0.
A function named addGas that accepts a parameter of type double . The value of the amount instance variable is increased by the value of the parameter.
A function named useGas that accepts a parameter of type double . The value of the amount data member is decreased by the value of the parameter. However, if the value of amount is decreased below 0 , amount is set to 0 .
A function named isEmpty that accepts no parameters and returns a boolean value. isEmpty returns a boolean value: true if the value of amount is less than 0.1 , and false otherwise.
A function named getGasLevel that accepts no parameters. getGasLevel returns the value of the amount data member.
class GasTank
{
private:
double amount;
public:
GasTank();
void addGas(double);
void useGas(double);
bool isEmpty();
double getGasLevel();
};
GasTank::GasTank(){amount = 0;}
void GasTank::addGas(double a){amount += a;}
void GasTank::useGas(double a){amount -= a; if (amount < 0) amount = 0; }
bool GasTank::isEmpty(){if(amount < .1) return true; else return false;}
double GasTank::getGasLevel() {return amount;}

Answers

Answer:

Explanation:

The following class code is written in Java and includes all of the required methods as requested in the question...

package sample;

class GasTank {

   private double amount = 0;

   private double capacity;

   public GasTank(double initialAmount) {

       this.capacity = initialAmount;

   }

   public void addGas(double addAmount) {

       this.amount += addAmount;

       if (amount > capacity) {

           amount = capacity;

       }

   }

   public void useGas(double subtractAmount) {

       this.amount -= subtractAmount;

       if (amount < 0) {

           amount = 0;

       }

   }

   public boolean isEmpty() {

       return (amount < 0.1);

   }

   public boolean isFull() {

       return (amount > capacity - 0.1);

   }

   public double getGasLevel() {

       return amount;

   }

   public double fillUp() {

       double difference = capacity - amount;

       amount = capacity;

       return difference;

   }

}

an affective website design should fullfill its intended by conveying its message while simultaneosly engaging the visitors?do you agree or disagree​

Answers

Answer: True

Explanation:

The statement that "an effective website design ought to be able to fulfill the function that it has by passing the message across while engaging the visitor at the same time" is true.

Some of thr factors which bring about a good website design are functionality, simplicity, imagery, consistency, colours, typography. A website that's well designed and built will help in the building of trust.

Which term is defined by the total operating current of a circuit?

Answers

Answer:

OK PERO NOSE LM SOTTY BROTHER

Explanation:

what is a computer?

Answers

an electronic device for storing and processing data, typically in binary form, according to instructions given to it in a variable program.

hope this helps

The information in DNA Is coded in chemical bases adenosine (A) guanine (G) cytosine (C), and thymine (T) We can represent a DNA strand by stringing together the letters representing the appropriate strand. Imagine we are given a list of DNA strands which have arbitrary lengths. Write a single function strand_counter() which takes a list of DNA strands, counts the lengths of each of the words in the list and then calculates and returns the integer maximum_length integer minimum_length, and float average_length
Then write a program which takes in a user-chosen number of strands of arbitrary length as an input and prints out the calculated information
Example input
5
AT
ATCGTCOGGT
TCGCT
TCGATTCCT
TTCATCG
Example output
The longest strand has length 10.
The shortest strand has length 2.
The average length of the strands is 6.6.

Answers

Answer:

c

Explanation:

i think i leard it out my old shcool

What is
Computer Security

Answers

Answer:

Computer Security is the protection of computer systems and networks from information disclosure, theft of or damage to their hardware, software, or electronic data, as well as from the disruption or misdirection of the services they provide.

Explanation:

Answer:

the protection of computer systems and information from theft

Explanation:

How do I create a flowchart to output numbers from n...1? We were doing loops during the classes.

Answers

I use GOxxOGLE FORMS or WxxORDS and their good to make flow charts

Which three major objects are built into the JavaScript language?
This task contains the radio buttons and checkboxes for options. The shortcut keys to perform this task are A to H and alt+1 to alt+9.
A

Document, Object, Model.
B

Canvas, Geolocation and Drag.
C

None, JavaScript is object-based not object-oriented.
D

Document, Navigator, Array.

Answers

Answer:

jddjjddjdjdjjsjsjejejejjejejejjdjdjeje

Pretty sure, the answer is: None, JavaScript is object-based not object-oriented.

giving Brianlist (to the correct answers)help plesee question is what is keyboard (long paragraph)​plzz don't spam with unnecessary answers !!!!thankyouuuuuuu:)

Answers

Answer:

Explanation:

A computer keyboard is an input device that allows a person to enter letters, numbers, and other symbols (these are called characters in a keyboard) into a computer. Using a keyboard to enter lots of data is called typing. A keyboard contains many mechanical switches or push-buttons called "keys".

Which of the following terms is associated with instant messaging?
A. buddy list
B.subject heading
C.Save As
D.texting

Answers

D.

Texting is associated with instant messaging

Answer: A buddy list is a term that is associated with instant messaging (IM)

Have a wonderful day :D

Explanation:

You are creating a Web document on a mobile device and will be out of your Internet Service Provider's coverage range for the remainder of the day. Which HTML5 API will allow you to continue working on the document?
This task contains the radio buttons and checkboxes for options. The shortcut keys to perform this task are A to H and alt+1 to alt+9.
A

Canvas
B

Offline Web application
C

Drag-and-drop
D

Geolocation

Answers

a, canvas yuh yuh yuh

true or false with reason :- carriage inword is carriage on purchases​

Answers

Answer:

True

Explanation:

Carriage on purchases is carriage inward. Explanation: Carriage inwards refers to the transportation costs required to be paid by the purchaser when it receives merchandise it ordered with terms FOB shipping point. Carriage inwards is also known as freight-in or transportation-in.

:)

suppose as a head software engineer you assign the job of creating a class to a subordinate. You want to specify thirty-eight different methods in which you are willing to detail the parameters each is to receive as well as what each returns. You, however, do not have the time to create the details of each method and wish to assign that work to the subordinate. What would be your best approach to ensure that the subordinate finishes the assigned job.

Answers

Answer:

jskjsjsjsjskdmsnjsnsnsns

what was his beliefs?

Answers

A belief is an attitude that something is the case, or that some proposition about the world is true.[1] In epistemology, philosophers use the term "belief" to refer to attitudes about the world which can be either true or false.[2] To believe something is to take it to be true; for instance, to believe that snow is white is comparable to accepting the truth of the proposition "snow is white". However, holding a belief does not require active introspection. For example, few carefully consider whether or not the sun will rise tomorrow, simply assuming that it will. Moreover, beliefs need not be occurrent (e.g. a person actively thinking "snow is white"), but can instead be dispositional (e.g. a person who if asked about the color of snow would assert "snow is white").[2]

There are various different ways that contemporary philosophers have tried to describe beliefs, including as representations of ways that the world could be (Jerry Fodor), as dispositions to act as if certain things are true (Roderick Chisholm), as interpretive schemes for making sense of someone's actions (Daniel Dennett and Donald Davidson), or as mental states that fill a particular function (Hilary Putnam).[2] Some have also attempted to offer significant revisions to our notion of belief, including eliminativists about belief who argue that there is no phenomenon in the natural world which corresponds to our folk psychological concept of belief (Paul Churchland) and formal epistemologists who aim to replace our bivalent notion of belief ("either we have a belief or we don't have a belief") with the more permissive, probabilistic notion of credence ("there is an entire spectrum of degrees of belief, not a simple dichotomy between belief and non-belief").[2][3]

Beliefs are the subject of various important philosophical debates. Notable examples include: "What is the rational way to revise one's beliefs when presented with various sorts of evidence?"; "Is the content of our beliefs entirely determined by our mental states, or do the relevant facts have any bearing on our beliefs (e.g. if I believe that I'm holding a glass of water, is the non-mental fact that water is H2O part of the content of that belief)?"; "How fine-grained or coarse-grained are our beliefs?"; and "Must it be possible for a belief to be expressible in language, or are there non-linguistic beliefs?".[2]

When did games begin to really take off?


A: when people began to live with formal laws

B: when people began to compete for limited resources

C: when people began to settle together in stable, organized communities

D: when people began to hunt nomadic animals, like buffalo

Answers

I think its b? or C? cause games didnt exist till the 90s mostly

What is the value of: 1 + int(3.5) / 2?
Select one:
a. 2
b. 2.25
C. 2.5
d. 3

Answers

Answer:

C (2.5)

Explanation:

int(3.5) = 3

So, using order of operations, (3/2)+1=2.5

The value of the expression value of: 1 + int(3.5) / 2 is known to be option C, which is (2.5).

What is the expression about?

In maths, an expression is known to be the composition of numbers, functions such as addition, etc.

Note that int(3.5) = 3

Therefore, using the given order of operations, (3/2)+1

=2.5

Therefore the answer =2.5 is correct.

Learn more about Expression  from

https://brainly.com/question/723406

#SPJ2

What is Typing?
And
What is Economic? ​

Answers

Answer:

what is typing: the action or skill of writing something by means a typewriter or computer

what is economic:a branch of knowledge concerned with production,consumption,and transfer of wealth.

(python) Given the formula for conversion from Celsius to Fahrenheit
Fahrenheit = 1.8 x Celsius + 32
Write a Python program that takes as input a temperature in degrees Celsius, calculates the temperature in degrees Fahrenheit, and display the result as output.

Answers

Answer:

initial_temp = float(input('Celsius Temperature: '))

final_temp = (initial_temp * 1.8) + 32

print(f'{final_temp} F')

I like the impact that the increasing number of social grants may have on the things mothers​

Answers

Answer:

yes. i do too.

Explanation:

what precautions should be taken to make a computer more secure ​

Answers

Answer:

To make a computer more secure

Explanation:

we have following ways :

1)we should have anti virus to protect our computer.

2)we should not play or look computer for a long time because it destroy our files

As in previous prelabs, you can enter all the necessary Java code fragments into the DrJava Interactions pane. If you get an error, enter the corrected code. If you get really mixed up, you can reset the interactions pane and try again. Write a while loop that computes the sum of the first 10 positive integers. Write a for loop that computes the sum the first 10 positive integers. For each loop, you should use two variables. One that runs through the first 10 positive integers, and one that stores the result of the computation. To test your code, what is the sum of the first 10 positive integers

Answers

Answer:

public class Main{

public static void main(String[] args) {

 //The While Loop

 int i = 1;

 int sum = 0;

 while(i <=10){

     sum+=i;

     i++;  }

 System.out.println("Sum: "+sum);

 //The for Loop

 int summ = 0;

 for(int j = 1;j<=10;j++){

     summ+=j;  }

 System.out.println("Sum: "+summ); } }

Explanation:

The while loop begins here

 //The While Loop

This initializes the count variable i to 1

 int i = 1;

This initializes sum to 0

 int sum = 0;

This while iteration is repeated until the count variable i reaches 10

 while(i <=10){

This calculates the sum

     sum+=i;

This increments the count variable i by 1

     i++;  }

This prints the calculated sum

 System.out.println("Sum: "+sum);

The for loop begins here

 //The for Loop

This initializes sum to 0

 int summ = 0;

This iterates 1 through 10

 for(int j = 1;j<=10;j++){

This calculates the sum

     summ+=j;  }

This prints the calculated sum

 System.out.println("Sum: "+summ); }

Other Questions
Once a Constitutional amendment has been proposed, to which of the selections below is it generally passed for formal ratification?Select one:A. state legislaturesB. state governorsC. CongressD. President How does the appearance of the handkerchief effect Othello? Please help me please help me thank you The idea is to get as much EMF produced from the sprinter running through it. If you were the Olympic coach on a year when there happens to be a global energy crisis, and medals were assigned based on how much EMF (or current) were produced by the sprinters, what 3 pieces of advice (one is quite obvious; the other two involve the fixed orientation of the baton and the maintained position of the baton within the circular solenoid cross-section) would you give your sprinters in order to win? I need help with this question How many atoms are in 90.43 moles of copper Estimate 51.286+37.43 by first rounding each number to the nearest whole number. I need this and fast i will mark brainliest How do you solve this and please use explanation if you can. 13x+22x2 +20x+18x2 7.3x+9x2 +6x+10x2PLZZZZ HELPPP ITS DUE TODAY!!! Choices are 15212460654590 Suppose a city with population 600,000 has been growing at a rate of 4% per year. If this rate continues, find the population of this city in 25 years. HELP ASAP AND USE IMAGE TO HELP!! a.2. The following examples are good conductors except:a. Silverb. MetalPlasticd. Copper 3.23 + 1.47 =What is the answer i've tried so many different ones an they never seem to be wright? What was Abraham Lincoln's dilemma during the civil war? what are some things that you would like to improve about yourself. THIS MUST BE TWO PARAGRAPHS Two angles are congruent if oil has a density of 8.5kg/L. what is the volume of 5.4kg oil How can the White Rose incident serve as a critique of those who stood by the side? Compare the change in pH with the addition of acid and base to deionized water and to a buffer.