暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

熟能生巧:python练习题系列1

小样有样儿 2021-09-28
818

点击上方蓝字(小样有样儿)关注我


勤能补拙是良训,一分辛劳一分才!Practice makes perfect!

本文分享python练习题及输出效果。

# 练习1---输出"Go Big Or Go Home!"

print("Go Big Or Go Home!")

Go Big Or Go Home!

# 练习2---输出程序员节的含义

print("1024(程序员之日)寓意:\n低调、踏实、\n核心1024M=1G,\n谐音一级棒")

024(程序员之日)寓意:

低调、踏实、

核心1024M=1G,      

谐音一级棒

# 练习3---模拟输出用户登陆输入窗口

print(" 丽江市新闻采编系统\n用户名:______\n密码:_______\n验证码:______ 3+5=?")

丽江市新闻采编系统

用户名:__        

密码:__

验证码:__ 3+5=?  

# 练习4---输出金庸先生的作品口诀

 print("#############")
 
 print(" 笑 飞 ")
 
 print(" 书 雪 ")
 
 print(" 神 连 ")
 
 print(" 侠 天 ")
 
 print(" 倚 射 ")
 
 print(" 碧 白 ")
 
 print(" 鸳 鹿 ")
 
 print("#############")


# 练习5---输出银行交易短信

 
 print(" 交易提醒")
 
 print("------------------")
 
 print("交易金额\t人民币300.00元")
 
 print("账号\t1576")
 
 print("卡类型\t交行信用卡")
 
 print("交易时间\t22日14时55分")
 
 print("可用额度\t人民币4304.24元") 
 
交易提醒
 ------------------
 
 交易金额       人民币300.00元
 账号   1576
 卡类型  交行信用卡
 交易时间       22日14时55分
 可用额度       人民币4304.24元

# 练习6---输出“eat our own dog food”

 
 print(" 想要满足用户需求吗")
 
 print("     |   ")
 
 print("----------------------")
 
 print("| eat our won dog food |")
 
 print("----------------------")
    想要满足用户需求吗
            |
 ----------------------
 | eat our won dog food |
 ----------------------

# 练习7--- 根据输入的年份计算年龄大小

 import datetime
 
 bornyear=input("请输入您的出生年份:")
 
 nowyear=datetime.datetime.now().year
 
 age=nowyear-int(bornyear)
 
 print("您的年龄为"+str(age)+"岁")
 
 if age < 18:
 
  print("您现在是未成年人。")
 
 if age >= 18 and age < 66:
 
  print("您现在是青年人。")
 
 if age >=66 and age < 80:
 
  print("您现在是中年人。")
 
 if age >=80:
 
  print("您现在是老年人。")

请输入您的出生年份:2000

您的年龄为21岁

您现在是青年人。

# 练习8--- 计算BMI指数

 # 计算BMI指数
 height = float(input("请输入您的身高(cm):"))
 weight = float(input("请输入您的体重(kg):"))
 bmi = weight/(height*height)
 # 判断身材是否合理
 if bmi < 18.5:
    print("您的BMI指数为:"+str(bmi))
    print("体重过轻")
 if bmi >= 18.5 and bmi < 24.9:
    print("您的BMI指数为:"+str(bmi))
    print("正常范围,请注意保持。")    
 if bmi >= 24.9 and bmi < 29.9:
    print("您的BMI指数为:"+str(bmi))
    print("超重")    
 if bmi >= 29.9:
    print("您的BMI指数为:"+str(bmi))
    print("肥胖")    

请输入您的身高(cm):178

请输入您的体重(kg):66.1

您的BMI指数为:0.0020862264865547276

体重过轻


END




需要您的一个“在看”




文章转载自小样有样儿,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论