CS8 Programming Assignment 02 Write some Python code that will calculate and pri
ID: 3686728 • Letter: C
Question
CS8 Programming Assignment 02Write some Python code that will calculate and print both the area of the circle and the volume of the sphere given a user-inputted radius. Both the area and the volume should be rounded to the nearest whole number. Relevant equations:
Be sure to use the value of pi in Python's math module.
When you run your program it should prompt the user with the following message:
The user can then input any floating point number, for example:
(Note the space between the prompt from the program and the number entered by the user.)
Then your program should print the area of the circle and the volume of the sphere with that radius, like so:
Write your code in a Python file named pa02.py, and submit your program using submit.cs web page.
Important: Add your full name and umail/CS email address as a comment in the first line of your file. Example:
# Alice Smartpants (smartpants@umail.ucsb.edu) submit.cs.ucsb.edu cs8 web page CS8 Programming Assignment 02
Write some Python code that will calculate and print both the area of the circle and the volume of the sphere given a user-inputted radius. Both the area and the volume should be rounded to the nearest whole number. Relevant equations:
Be sure to use the value of pi in Python's math module.
When you run your program it should prompt the user with the following message:
The user can then input any floating point number, for example:
(Note the space between the prompt from the program and the number entered by the user.)
Then your program should print the area of the circle and the volume of the sphere with that radius, like so:
Write your code in a Python file named pa02.py, and submit your program using submit.cs web page.
Important: Add your full name and umail/CS email address as a comment in the first line of your file. Example:
# Alice Smartpants (smartpants@umail.ucsb.edu) submit.cs.ucsb.edu cs8 web page CS8 Programming Assignment 02
Write some Python code that will calculate and print both the area of the circle and the volume of the sphere given a user-inputted radius. Both the area and the volume should be rounded to the nearest whole number. Relevant equations:
Be sure to use the value of pi in Python's math module.
When you run your program it should prompt the user with the following message:
The user can then input any floating point number, for example:
(Note the space between the prompt from the program and the number entered by the user.)
Then your program should print the area of the circle and the volume of the sphere with that radius, like so:
Write your code in a Python file named pa02.py, and submit your program using submit.cs web page.
Important: Add your full name and umail/CS email address as a comment in the first line of your file. Example:
# Alice Smartpants (smartpants@umail.ucsb.edu) submit.cs.ucsb.edu cs8 web page
Explanation / Answer
#sarika tiwari (sarika_dangwal@yahoo.com)
import math
radius = input("Enter Radius: ")
print("Radius: " + str(radius))
r = float(radius)
volume = 4.0/3.0 * math.pi * (r*r*r)
print("Volume of sphere: " + str(round(volume,2)))
pi=3.14159
area=pi*r*r
print("Area of circle: " + str(round(surface,2)))