python获取从命令行输入数字的方法
作者:重负在身 时间:2021-08-23 15:19:02
本文实例讲述了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程序设计有所帮助。
标签:python,命令行,数字
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
js+csss实现的一个带复选框的下拉框
2023-08-18 03:11:19
![](https://img.aspxhome.com/file/2023/9/56099_0s.gif)
python 实现批量xls文件转csv文件的方法
2023-08-29 10:25:26
GO的range具体使用
2023-07-21 03:27:27
Orcas中C#语言的新特性:自动属性,对象初始化器,和集合初始化器
2007-09-23 12:43:00
Oracle中instr函数使用方法
2023-07-23 19:14:06
ASP分段读取数据库代码
2009-10-12 12:28:00
Python3利用Dlib实现摄像头实时人脸检测和平铺显示示例
2021-12-14 16:37:30
![](https://img.aspxhome.com/file/2023/0/76030_0s.gif)
构建成功web应用的十项黄金法则
2010-09-17 19:11:00
![](https://img.aspxhome.com/file/UploadPic/20109/17/01-99s.jpg)
WEB开发中合理选择图片格式
2011-09-22 20:32:06
asp获取数据库中表名和字段名的代码
2011-04-18 11:02:00
Bootstrap响应式侧边栏改进版
2023-08-17 02:26:10
![](https://img.aspxhome.com/file/2023/1/56051_0s.jpg)
Javascript"篱式"条件判断(翻译)
2008-08-01 12:21:00
常见数据库系统比较 Oracle数据库
2010-07-28 12:44:00
设计MySQL数据库的技巧
2009-09-06 11:56:00
![](https://img.aspxhome.com/file/UploadPic/20099/6/20099612300822s.jpg)
asp和php页面全面封杀WVS扫描器的代码
2011-02-28 10:43:00
asp如何用SA-FileUp上传多个文件?
2010-06-13 14:34:00
困惹的A标签
2007-12-04 12:36:00
![](https://img.aspxhome.com/file/UploadPic/200712/4/2007124125051635s.png)
js实现网页加载loading的显示
2007-11-06 12:11:00
![](https://img.aspxhome.com/file/UploadPic/200711/6/2007116122626422s.jpg)
oracle 触发器 学习笔记
2009-05-24 19:57:00
Python实现绘制多种激活函数曲线详解
2022-06-30 01:02:06
![](https://img.aspxhome.com/file/2023/8/78488_0s.png)