Python Programming: An Introduction to Computer Science, 3rd Ed.
Python Programming: An Introduction to Computer Science, 3rd Ed.
3rd Edition
ISBN: 9781590282755
Author: John Zelle
Publisher: Franklin, Beedle & Associates
Question
Book Icon
Chapter 10, Problem 9PE
Program Plan Intro

Sphere

Program Plan:

Sphere.py

  • Import the required packages.
  • Definition of main method
    • Get the radius of the sphere
    • Call the method “Sphere()” by passing the parameter “rad”.
    • Call the method “surfaceArea()”.
    • Call the method “volume()”.
    • Print the volume of the sphere
    • Print the area of the sphere.
  • Call the main function

Main.py:

  • Import the required packages
  • Definition of class sphere
    • Definition of method “init()”.
      • Assign the value of radius.
    • Definition of method “getRadius()”.
      • Return the value of radius.
    • Definition of method “surfaceArea()”.
      • Calculate surface area
    • Definition of method “volume()”.
      • Calculate the volume.
    • Return the volume.

Blurred answer
Students have asked these similar questions
Create a rectangle class that can compute the area and the sum of its sides.  Create a specialized method that will allow the class to compare other rectangle objects.  The comparison should identify the larger rectangle according to the object’s area.  You should be able to implement the class where the user provides rectangle dimensions.  The program should be able to display which of the rectangle inputs is larger using the Rectangle class method that you defined. Sample output: Enter Length R1:  1 Enter Width  R1:  1 Enter Length R2:  2 Enter Width  R2:  2 Results: R1 Area: 1 R1 Sum: 2 R2 Area: 4 R2 Sum: 4 R2 is the bigger Rectangle!   Note:  All characters in boldface are user inputs.
Design an application that does the following: A Solid can be a FlatSurfaceSolid or a CurvedSurfaceSolid. Every solid will have a volume. The method volume will be polymorphic. A solid has faces, vertices and edges. A flat-surface solid also has a variable called side which represents the length of the side. A curved-surface solid also has a radius. A Cube is a FlatSurfaceSolid. A cube has 6 faces, 8 vertices and 12 edges. It will have a side. A Sphere is a CurvedSurfaceSolid. It has 1 face, 0 vertices and 0 edges. It will have a radius. Create an ArrayList of solids (driver file named YourLastNameCISC231Q1.java). The arraylist will have 4 elements – 2 cubes (one with side length 3 and another will side length 4) and 2 spheres (one with radius 3 and another with radius 4). Create a driver class to instantiate an array of solids and display the details of each solid along with the volume of each solid.
Implement the critter class. Each critter C has attributes species, size, and age. • The constructor accepts arguments for the attributes above, in the order above. You can expect size and age to be numeric values. Each critter C has a can_eat () method, which: Receives one argument, prey, which you can expect to be another Critter object. Compares prey 's size against C's. o If C is larger than prey, return True. Otherwise, return False. Each critter C also has a survive_year () method, which: • Increases C's size and age by 1, respectively, and returns C's current size.
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education