The formula for calculating the circumference of a circle is 2*π*r. The formula for calculating the area of a circle is π*r*r. Write a Python class named Wheel, constructed by a radius and two methods, which will calculate the perimeter (circumference) and the surface area of a wheel (circle). The script should ask for the user's input for the radius, create a Wheel object, and print out its surface area and perimeter. It should ask for the user's input again after it prints the surface area and perimeter each time. You should use the math modules and set the pi constant as your value for pi. Our aim here is to practice defining methods in a class. Open the file named main.py. Define the Wheel class and the Wheel constructor method. Create the wheel_area calculation method, which returns the surface area of the wheel. Create the wheel_perimeter calculation method, which returns the perimeter of the wheel. Create the swap_radius method, which sets new_radius as the radius of the wheel when requested from user input. After the class definition, add the code that requests for user input for the radius of the wheel. Create a __main__ and add a while loop so that the request for user input runs multiple times. In the while loop, we'll request the user input, change the Wheel object's radius using the swap_radius method, and then print out the surface area and perimeter of the wheel. Make sure that your program terminates properly when the user indicates they would like to quit. You can run the script by using python3 main.py command. The script will ask for user input, calculate the surface area and perimeter, print that out, and ask for your input again.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

The formula for calculating the circumference of a circle is 2*π*r. The formula for calculating the area of a circle is π*r*r.

Write a Python class named Wheel, constructed by a radius and two methods, which will calculate the perimeter (circumference) and the surface area of a wheel (circle).

  • The script should ask for the user's input for the radius, create a Wheel object, and print out its surface area and perimeter.
  • It should ask for the user's input again after it prints the surface area and perimeter each time.
  • You should use the math modules and set the pi constant as your value for pi.

Our aim here is to practice defining methods in a class.

  1. Open the file named main.py.

  2. Define the Wheel class and the Wheel constructor method.

  3. Create the wheel_area calculation method, which returns the surface area of the wheel.

  4. Create the wheel_perimeter calculation method, which returns the perimeter of the wheel.

  5. Create the swap_radius method, which sets new_radius as the radius of the wheel when requested from user input.

  6. After the class definition, add the code that requests for user input for the radius of the wheel.

  7. Create a __main__ and add a while loop so that the request for user input runs multiple times. In the while loop, we'll request the user input, change the Wheel object's radius using the swap_radius method, and then print out the surface area and perimeter of the wheel.

Make sure that your program terminates properly when the user indicates they would like to quit.

  1. You can run the script by using python3 main.py command. The script will ask for user input, calculate the surface area and perimeter, print that out, and ask for your input again. 
AI-Generated Solution
AI-generated content may present inaccurate or offensive content that does not represent bartleby’s views.
steps

Unlock instant AI solutions

Tap the button
to generate a solution

Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education