Python廖雪峰教程中的代码·1

原创
2017/04/20 17:39
阅读数 78
# -*- coding: utf-8 -*-
print("你好")
print('hello world')
print('hello','world') ##','相当于空格
print('1024*768=',1024*768)##计算
#一个简单的交互,交互要在REPL里写
name = input('Please input your name:')
print('你好,',name)
#格式化语言编辑:你好,xx,您本月花费为xx。
'hello,%s'%('world')
'Hi,%s,you have $%d' % ('Lily',10000)
'%3d-%04d'%(303,502)
S1 = 72
S2 = 85
r = (S2-S1)/S1*100
##格式化语句
print('小明的成绩提高了:','%.1f'%r,'%')
##转义符
print(r'Hello,'Xixi'
	you should change your password.')
print('Lisa\'\'\'')
print(r'''This's a test.
	\n \t \f
	so you don't need minding it.''')
##if else语句
s = input('Plz input your birth:')
b = int(s)
if b >=2000:
    print('You are a after-00.')
else:
    print('You are a before-00.')
####BMI指数计算23333一定要注意数字类型啊类型!
height = float(input('Plz input your height:'))
weight = float(input('Plz input your weight:'))
BMI = weight/(height*height)
if BMI < 18.5:
	print('过轻')
elif BMI <25:
	print('正常')
elif BMI <28:
	print('微胖')
elif BMI <32:
	print('肥胖')
else:
	print('严重肥胖')

 

展开阅读全文
打赏
0
0 收藏
分享
加载中
更多评论
打赏
0 评论
0 收藏
0
分享
返回顶部
顶部