Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Step: 3

blur-text-image

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

Databases Organizing Information Digital And Information Literacy

Authors: Greg Roza

1st Edition

1448805929, 978-1448805921

More Books

Students also viewed these Databases questions