您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

python获取从命令行输入数字的方法

2024/5/27 12:01:50发布17次查看
本文实例讲述了python获取从命令行输入数字的方法。分享给大家供大家参考。具体如下:
#----------------------------------------# 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程序设计有所帮助。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product