#----------------------------------------# name: numerical_input.py# author: kevin harris# last modified: 02/13/04# description: this python script demonstrates # how to get numerical input# from the command line # and use the if-else conditional.#----------------------------------------print()print( welcome to the area calculation program )print( --------------------------------------- )print()# print out the menu:print( please select a shape: )print( 1 rectangle )print( 2 circle )print()# the input function both prompts the user# for input and fetches it...shape = int( input( > ) )# calculate the area...if shape == 1: height = int( input(please enter the height: ) ) width = int( input(please enter the width: ) ) area = height*width print( the area is, area )else: radius = int( input(please enter the radius: ) ) area = 3.14*(radius**2) print( the area is, area )input( '\n\npress enter to exit...' )
希望本文所述对大家的python程序设计有所帮助。
