Question

In: Computer Science

Hello Everyone, Can anyone tell me why my program will not run? I am trying to...

Hello Everyone,

Can anyone tell me why my program will not run? I am trying to work on abstract base classes... not sure what is going on.

import math

from abc import ABC

from abc import abstractmethod

#TODO: convert this to an ABC

class Shape(ABC):

def __init__(self):

self.name = ""

def display(self):

print("{} - {:.2f}".format(self.name, self.get_area()))

#TODO: Add an abstractmethod here called get_area

@abstractmethod

def get_area(self):

if self.name == "Circle":

get_area()= 3.14 * radius * radius

else:

get_area() = self.length * self.width


#TODO: Create a Circle class here that derives from Shape

class Circle(Shape):

def __init__(self):

super().__init__()

self.name = "Circle"

self.radius = 0.0

get_area()

#TODO: Create a Rectangle class here that derives from Shape

class Rectangle(Shape):

def __init__(self):

super().__init__()

self.name = "Rectangle"

self.length = 0.0

self.width = 0.0

get_area()


def main():

#TODO: Declare your list of shapes here

s = Shape()

c = Circle()

r = Rectangle()

radius = []

length = []

width = []

command = ""

while command != "q":

command = input("Please enter 'c' for circle, 'r' for rectangle or 'q' to quit: ")

if command == "c":

radius = float(input("Enter the radius: "))

#TODO: Declare your Circle here, set its radius, and

# add it to the list

self.name = "Circle"

radius.apphend

return radius

elif command == "r":

length = float(input("Enter the length: "))

width = float(input("Enter the width: "))

#TODO: Declare your Rectangle here, set its length

# and width, and add it to the list

self.name = "Rectangle"

return length, width

length.apphend

width.apphend


# Done entering shapes, now lets print them all out:

s.display()

#TODO: Loop through each shape in the list, and call its display function

for i in Shape():

s.display()

if __name__ == "__main__":

main()

Solutions

Expert Solution

Note:

Is is properly indented?

Please send me the screenshot of an error, or you can do one thing, you can copy paste the error messages in the comment section.

Note:

I tried executing the code, and here's the problem
get_area()= 3.14 * radius * radius

You cannot directly assign the numeric, decimal values to the function which is causing an error.

Follow up this indentation:


Related Solutions

Can anyone explain to me why I am getting an access violation when I try to...
Can anyone explain to me why I am getting an access violation when I try to add notes? It occurs when I try to set the "pLast" pointer to the previous node (for a doubly linked list). The code worked as singly linked list. When I added a "pLast" pointer and the needed code to make it a doubly linked list everything broke. #include <iostream> #include <stdlib.h> using namespace std; //build class that has a private function to inc count....
can anyone tell me the reason why if the number of basis is equal to the...
can anyone tell me the reason why if the number of basis is equal to the dimension of a vector space V then it is the basis of the vector space V. and also what the theorem is? since, I think if V=span{(1,0,0), (0,1,0)} and dim(V)=2 and basis={(1,0,0), (0,0,1)} which the number is also 2. but it is not the basis of V. So, can you tell where is the mistake. THANK YOU!
Hello, I am trying to write a C++ program that will do the following: Use the...
Hello, I am trying to write a C++ program that will do the following: Use the STL stack container in a program that reads a string, an arithmetic expression to be exact, one character at a time, and determines if the string has balanced parenthesis – that is, for each left parenthesis there is exactly one matching right parenthesis later in the string.                         Use the following strings to test your program. A+ B - C A * B / (C...
Hello All, anyone can explain these to me? I. What’s the effect of increasing the capacitance?...
Hello All, anyone can explain these to me? I. What’s the effect of increasing the capacitance? in term of saturation mode II. What’s the effect of decreasing the capacitance? in term of saturation mode III. Does dose saturation mode mean a short circuit? IV. What will happen to the capacitor under saturation mode? V. What's the relationship between the temp and the capacitance? curious to know the answers for these questions
Can someone please tell me why I am getting errors. I declared the map and it's...
Can someone please tell me why I am getting errors. I declared the map and it's values like instructed but it's telling me I'm wrong. #include <iostream> #include <stdio.h> #include <time.h> #include <chrono> #include <string> #include <cctype> #include <set> #include <map> #include "d_state.h" using namespace std; int main() { string name; map<string,string> s; map<string,string>::iterator it; s[“Maryland”] = "Salisbury"; s[“Arizona”] = "Phoenix"; s[“Florida”] = "Orlando"; s[“Califonia”] = "Sacramento"; s[“Virginia”] = "Richmond"; cout << "Enter a state:" << endl; cin >> name;...
Can anyone please tell me what function in excel I could use in this instance: I...
Can anyone please tell me what function in excel I could use in this instance: I have two spreadsheets with sales of products for a company. I am needing to create a new spreadsheet with gross sales by month and by region. It haven't included all the worksheets, because I truly just need pointed in the right direction.
can someone tell me if i am wrong on any of these???? THANKS In order to...
can someone tell me if i am wrong on any of these???? THANKS In order to be able to deliver an effective persuasive speech, you need to be able to detect fallacies in your own as well as others’ speeches. The following statements of reasoning are all examples of the following fallacies: Hasty generalization, mistaken cause, invalid analogy, red herring, Ad hominem, false dilemma, bandwagon or slippery slope. 1. __________bandwagon fallacy_______ I don’t see any reason to wear a helmet...
Hello! I am doing an advertisment campaign, I recieved the most vague instructions ever, can anyone...
Hello! I am doing an advertisment campaign, I recieved the most vague instructions ever, can anyone clarify if you have any idea? Step 1: SWOT Analysis for the Advertising Client (20%)  Key communications goals should emerge from this analysis Step 2: Target Market Assignment (20%)  Who, what need, where, when, why client solution and how (solution) Step 3: Brand Identity Assignment (20%)  Key image, message, positioning and rationale supported by Steps 1 &2 Step 4: Promotional Strategy...
Can anyone tell me about the measurement of ICP-AES?
Can anyone tell me about the measurement of ICP-AES?
I am writing a shell program in C++, to run this program I would run it...
I am writing a shell program in C++, to run this program I would run it in terminal like the following: ./a.out "command1" "command2" using the execv function how to execute command 1 and 2 if they are stored in argv[1] and argv[2] of the main function?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT