<<Python编程实践>>之Choose

#!/usr/bin/python
#encoding:utf8

#ph值判别程序
print "Please input a ph value: "
def phchoose(ph):
	'''ph value and choose acidic or basic'''
	if ph < 7.0:
	    print "ph value %s is acidic." % ph
	elif ph > 7.0:
		print "ph value %s is basic." % ph
	else:
		print "ph value %s is neutral." % ph

ph = float(raw_input())
phchoose(ph)

#年龄体重指数和患心脏病的关系
#---------------年龄---
#------------< 45    >=45
#体重< 22.0  低      中
#指数>=22.0  中      高

#method_1
def method1(age,bmi):
	if age < 45:
		if bmi < 22.0:
			return 'risk = low'
		else:
		    return 'risk = medium'
	else:
		if bmi < 22.0:
			return 'risk = medium'
		else:
			return 'risk = high'

print "Please input age and bmi: "
age = int(raw_input())
bmi = float(raw_input())
print "Age %d Bmi %s" % (age,bmi),
risk = method1(age,bmi)
print risk

#method_2
def method2(age,bmi):
	young = age < 45
	slim  = bmi < 22.0
	if young:
		if slim:
			return 'risk = low'
		else:
			return 'risk = medium'
	else:
		if slim:
			return 'risk = medium'
		else:
			return 'risk = high'
risk2 = method2(age,bmi)
print 'method2 : ', risk2

#method_3
def method3(age,bmi):
	young = age < 45
	slim  = bmi < 22.0
	if young and slim:
		return 'risk = low'
	elif young and not slim:
		return 'risk = medium'
	elif not young and slim:
		return 'risk = medium'
	elif not young and not slim:
		return 'risk = high'
risk3 = method3(age,bmi)
print 'method3 : ',risk3

#mehtod_4
young = age < 45
heavy = bmi >= 22.0
table = [['medium','high'],['low','medium']]
risk = table[young][heavy]
print 'method4 :  risk =',risk


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
ERROR: Ignored the following versions that require a different python version: 1.10.10 Requires-Python >=3.6,<3.8; 1.10.11 Requires-Python >=3.6,<3.8; 1.10.12 Requires-Python >=3.6,<3.8; 1.10.13 Requires-Python >=3.6,<3.8; 1.10.14 Requires-Python >=3.6,<3.8; 1.10.15 Requires-Python >=3.6,<3.8; 1.10.16 Requires-Python >=3.6,<3.8; 1.10.17 Requires-Python >=3.6,<3.8; 1.10.18 Requires-Python >=3.6,<3.8; 1.10.19 Requires-Python >=3.6,<3.8; 1.10.20 Requires-Python >=3.6,<3.8; 1.10.21 Requires-Python >=3.6,<3.8; 1.10.22 Requires-Python >=3.6,<3.8; 1.10.23 Requires-Python >=3.6,<3.8; 1.10.24 Requires-Python >=3.6,<3.8; 1.10.25 Requires-Python >=3.6,<3.8; 1.10.26 Requires-Python >=3.6,<3.8; 1.10.3 Requires-Python >=3.6,<3.8; 1.10.4 Requires-Python >=3.6,<3.8; 1.10.5 Requires-Python >=3.6,<3.8; 1.10.6 Requires-Python >=3.6,<3.8; 1.10.7 Requires-Python >=3.6,<3.8; 1.10.8 Requires-Python >=3.6,<3.8; 1.10.9 Requires-Python >=3.6,<3.8 ERROR: Could not find a version that satisfies the requirement tensorflow~=1.14.0 (from rasa) (from versions: 2.2.0, 2.2.1, 2.2.2, 2.2.3, 2.3.0, 2.3.1, 2.3.2, 2.3.3, 2.3.4, 2.4.0, 2.4.1, 2.4.2, 2.4.3, 2.4.4, 2.5.0, 2.5.1, 2.5.2, 2.5.3, 2.6.0rc0, 2.6.0rc1, 2.6.0rc2, 2.6.0, 2.6.1, 2.6.2, 2.6.3, 2.6.4, 2.6.5, 2.7.0rc0, 2.7.0rc1, 2.7.0, 2.7.1, 2.7.2, 2.7.3, 2.7.4, 2.8.0rc0, 2.8.0rc1, 2.8.0, 2.8.1, 2.8.2, 2.8.3, 2.8.4, 2.9.0rc0, 2.9.0rc1, 2.9.0rc2, 2.9.0, 2.9.1, 2.9.2, 2.9.3, 2.10.0rc0, 2.10.0rc1, 2.10.0rc2, 2.10.0rc3, 2.10.0, 2.10.1, 2.11.0rc0, 2.11.0rc1, 2.11.0rc2, 2.11.0, 2.11.1, 2.12.0rc0, 2.12.0rc1, 2.12.0, 2.13.0rc0, 2.13.0rc1) ERROR: No matching distribution found for tensorflow~=1.14.0
06-13
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Digital2Slave

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值