Question: Question: In python I am writing this code but it is not producing the right output I want for picking the shape how can I

Question: In python I am writing this code but it is not producing the right output I want for picking the shape how can I fix that? Also how would I begin the other parts for each of the shapes.

Write a program that first prompts the user to choose one of the following 3-d shapes:

  1. a octahedron
  2. a right circular cone
  3. a sphere
  4. a cube

You should prompt the user and then wait for their input. When the user enters an invalid shape, you should print a warning and then prompt them again. When they enter a valid selection, the program should continue.

Next, prompt the user to choose what to calculate:

  1. surface area
  2. volume

You should prompt the user and then wait for their input. When the user enters an invalid calculation, you should print a warning and then prompt them again. When they enter a valid selection, the program should continue.

Next, depending on which shape the user entered, ask for the shape's dimensions. All values for shape dimensions should work for floating point numbers. After you have all the appropriate information, output the requested data. Add labels for all inputs and outputs. The output should be similar to the sample output in the sample runs below. You do not need to check for bad input during this phase.

Code:

import stdio import math import sys

print("Welcome to Geometric Calulator")

print( " " )

while True: print("Enter a shape:"' ' + "1 = octahedron"' ' + "2 = cone"' ' + "3 = sphere"' ' + "4 = cube"' ' )

shape = stdio.readInt()

if shape == 1: print("You picked Octahedron") break

elif shape == 2: print("You picked Cone") break

elif shape == 3: print("You picked Sphere") break

elif shape == 4: print("You picked Cube") break

else: print("You picked a number outside of range. Try Again!")

print("Enter a shape:"' ' + "1 = octahedron"' ' + "2 = cone"' ' + "3 = sphere"' ' + "4 = cube"' ' )

shape = stdio.readInt()

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!