Question

In: Computer Science

Hey, I have a code that I am working on to make a garden plot calculator,...

Hey, I have a code that I am working on to make a garden plot calculator, however I am reaching an error that I cannot seem to get past. Please help.

import math

# GarednPlot contains all the utility functions
class GardenPlot:

    # constructor function: Welcomes the user and sets default values
    def __init__(self):
        print("Welcome!")
        self.length = 0
        self.radius = 0
        self.depth = 0

    # Sets the length of the GardenPlot and returns that length
    def setLength(self):
        self.length = float(input("Enter length of the garden: "))
        return self.length

    # Sets the radius of the Fountain in the GardenPlot and returns that radius
    def setRadius(self):
        self.radius = float(input("Enter radius of the fountain: "))
        return self.radius

    # Sets the depth of the GardenPlot/Flower-bed and returns that depth
    def setDepth(self):
        self.depth = float(input("Enter depth of the flower bed: "))
        return self.depth

    # Returns the total area of the GardenPlot using the given formula
    def area_of_garden(self):
        return round((self.length * self.length), 1)

    # Returns the total area of the Fountain in the GardenPlot using the given formula
    def area_of_fountain(self):
        # round() rounds of the output to 1 decimal place
        return round((math.pi * self.radius * self.radius), 1)

    # Returns the total area of the flower bed
    def area_of_flowerbed(self):
        # Area of Flower-bed = Area of GardenPlot - Area of Fountain
        return round((self.area_of_garden() - self.area_of_fountain()), 1)

    # Returns the volume of the flower bed using the given formula
    def volume_of_soil(self):
        volume = self.area_of_flowerbed() * self.depth
        return round(volume, 1)

    # Prints the final stats of the Garden Plot
    def main(self):
        print("Total area of garden plot: "+ str(self.area_of_garden()))
        print("Total area of flower bed: "+ str(self.area_of_flowerbed()))
        print("Total amount of soil needed: "+ str(self.volume_of_soil()))


# Driver function
if __name__ == "__main__":
    # Create the object
    plot = GardenPlot()

    # Prompts user and displays all the inputs one after the other
    length = plot.setLength()
    print("Length: " + str(length))
    radius = plot.setRadius()
    print("Radius: " + str(radius))
    depth = plot.setDepth()
    print("Depth: " + str(depth))

    # Print stats
    plot.main()

and here is the error that I keep recieving:

Enter length of the garden: Traceback (most recent call last):
  File "main.py", line 60, in <module>
    length = plot.setLength()
  File "main.py", line 15, in setLength
    self.length = float(input("Enter length of the garden: "))
EOFError: EOF when reading a line

Solutions

Expert Solution

The problem that you are getting is probably compier specific.

You did not call your def main() of the class GardenPlot . After calling the setters and calling the main of the class with random input following three output from three different platform are begin attached.

This is the code you have given.

plot.main() has been called at the end of calling the setters.

This code has been compiled on jupyter OnlinGDB and python command line interface.

This is the output you get in Jupyter

This is the output you get in OnlineGDB

This is the answer you get in command line execution

I am using the latest version of python that is python 3.9.

Please ask if any doubt is there


Related Solutions

Garden Plot Calculator Assume that you have a garden plot like the following: The blue circle...
Garden Plot Calculator Assume that you have a garden plot like the following: The blue circle represents a fountain and the orange part the flower bed. Remember that the area of a square is the length of oneof its sides squared. Also, the area of a circle is πr, where r is the radius of the circle. The volume is the square footage times thedepth.For this project, you get to write a Python script to perform some calculations for the...
Working with Python. I am trying to make my code go through each subject in my...
Working with Python. I am trying to make my code go through each subject in my sample size and request something about it. For example, I have my code request from the user to input a sample size N. If I said sample size was 5 for example, I want the code to ask the user the following: "Enter age of subject 1" "Enter age of subject 2" "Enter age of subject 3" "Enter age of subject 4" "Enter age...
Plot the function without using a calculator, as you will not have a calculator on the...
Plot the function without using a calculator, as you will not have a calculator on the exams. a. ? = 34 sin ?, from t = 0 to the end of the first cycle only. b. ? = 2sin3?, from t = 0 to the end of the second cycle only. c. ? = 2cos3?, from t = 0 to the end of the second cycle only. d. ? = 2sin??, from t = 0 to the end of the...
Attached is the problem I am working on I have to use phantoms, and i have...
Attached is the problem I am working on I have to use phantoms, and i have already completed steps p and H, I need help help with step A , which is to "state and check the assumptions for the hypothesis test", I think the correct hypothesis test to use would be the 2 sample t test, but im not sure. The number of cell phones per 100 residents in countries in Europe is given in table #9.3.9 for the...
I am trying to make a new code that uses functions to make it. My functions...
I am trying to make a new code that uses functions to make it. My functions are below the code. <?php */ $input; $TenBills = 1000; $FiveBills = 500; $OneBills = 100; $Quarters = 25; $Dimes = 10; $Nickels = 5; $Pennies = 1; $YourChange = 0; $input = readline("Hello, please enter your amount of cents:\n"); if(ctype_digit($input)) { $dollars =(int)($input/100); $cents = $input%100;    $input >= $TenBills; $YourChange = (int)($input/$TenBills); $input -= $TenBills * $YourChange; print "Change for $dollars dollars...
Hey There! .... I am Joseph the Pizza Maker! I operate a thriving pizzeria and I...
Hey There! .... I am Joseph the Pizza Maker! I operate a thriving pizzeria and I am generating a significant amount of profit. So much profit ... that I have to find a way to offset the income and avoid the income taxes. So I bought this cool Corvette for $60,000 and I am going to use it to deliver a few pizzas. That will allow me to write off about $15,000 per year over the next four years. That...
Hi! I am working on a lab for Organic Chemistry and I want to make sure...
Hi! I am working on a lab for Organic Chemistry and I want to make sure my answers are correct before submitting it! Thank you in advance! Stereoisomerism: A Model Exercise In this experiment you will construct models with your molecular model set that illustrate the concepts of chirality, chiral center (stereogenic center, asymmetric carbon atom), enantiomers, diastereomers, and meso forms. You will also learn about two conventions, R-S and Fischer, for designating the configurations of chiral molecules. You will...
I am working on a project that requires a measurement of acceleration. I have a ADXL345...
I am working on a project that requires a measurement of acceleration. I have a ADXL345 accelerometer, an aduino and a MAX7219 dot matrix display. I need help setting up a code for my aduino to display the acceleration from the ADXL345 accelerometer onto the MAX7219 display. Please help!
Hey I am trying to find a way to find the position of a Red Dwarf...
Hey I am trying to find a way to find the position of a Red Dwarf star that is in an elliptical orbit at a certain time during it's orbit. I know the Red Dwarf's semi major axis which is 3 AU (astronomical unit) and it's period is 1896 days. I've tried to do a simple using its orbit velocity and doing distance=velocity x time, but I wasn't getting answers that made sense. If anyone could set me on the...
Hello, I am working on an assignment but I am unsure of how to solve it....
Hello, I am working on an assignment but I am unsure of how to solve it. Please help me. The assignment details are below. Consider this scenario: Your friend starts a website, nothingbutflags.com, which is not making money. Your friend asks you to help generate more traffic. You ask your friend how much traffic the website had last month? And your friend replies and says only 500 visits. You also ask how many flags did you sell? Your friend replies...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT