Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

***Please revise the following code. Do not copy previous answers, as they have resulted in errors. No input function, please use sys.argv*** Write a program

***Please revise the following code. Do not copy previous answers, as they have resulted in errors. No input function, please use sys.argv***

Write a program and create the following functions: shapes(): takes the shape name and a number as parameters, and calls the proper function to calculate the area. areaCircle(): take one number as a parameter, calculates the area of the circle, and print the result. Round the output to 2 decimal places. areaSquare(): takes one number as a parameter, calculates the area of the circle, and prints the result. Round the output to 2 decimal places. You can assume the shape names will be circle or square (nothing else). The program output is shown below.

Input:

a) python C:\Users eda\DataProgramming\M4\assign4-6.py circle 10

b) python C:\Users eda\DataProgramming\M4\assign4-6.py square 5

Output:

a) The circle area is 314.16

b) The square are is 25

Python code:

import math def areaSquare(side): area = side*side print("The square area is {0:.2f}".format(area)) def areaCircle(rad): area = math.pi*rad*rad print("The circle area is {0:.2f}".format(area)) if types=="square": side = int(input()) areaSquare(side) elif types == "circle": rad = int(input()) areaCircle(rad) shapes(input())

image text in transcribed

C:\Usersi python C: \Users, assign4-6.py circle 10

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

SQL For Data Science Data Cleaning Wrangling And Analytics With Relational Databases

Authors: Antonio Badia

1st Edition

3030575918, 978-3030575915

More Books

Students also viewed these Databases questions