python字符串
来源:互联网 发布:gta5光盘淘宝店家 编辑:程序博客网 时间:2024/06/07 07:14
下边是几个测试题
#请用户输入成绩,分别统计90分以上,70-90.60-70,60一下各多少人
'''a,b,c,d=0,0,0,0while True: score=input("请输入成绩:") score=int(score) if score>=90 and score<=100: a+=1 elif score>=70 and score<90: b+=1 elif score>=60 and score<70: c+=1 elif score<60: d+=1 else: print("输入有误") continue tag=input("是否继续y/n") if tag=="n": breakprint("90分以上有:",a,"人")print("70-90分有:",b,"人")print("60-70分有:",c,"人")print("60分以下有:",d,"人")'''2.#请用户输入一个四位数字:求此数字各个位之和(循环实现)
'''s=input("请输入一个四位数字:")s=int(s)ge=s%10shi=s//10bai=s//100qian=s//1000sum=ge+shi+bai+qianprint(sum)'''3.#用户输入月份,判断当前月份为几月,并输出有多少天。如果用户输入2月份,则请用户输入年份,判断平年则输出28天,闰年则输出29天。
while True: i=int(input("请输入月份:")) month=[1,3,5,7,8,10,12] if i in range(1,13): if i in month: print(i,"月有31天") elif i==2: p=int(input("请输入年份:")) if p%400==0 and(p%4==0 or p%100!=0): print(p,"年2月份是闰年有29天") else: print(p,"年二月份是平年有28天") else: print("这年",i,"月有30天") else: print("输入有误") tag=input("是否继续查询,y/n") if tag=="n": print("谢谢使用") break
Python常用的一些字符
阅读全文
0 0
- Python字符串
- Python 字符串
- python字符串
- python 字符串
- 【python】-字符串
- python 字符串
- python字符串
- python 字符串
- python,字符串
- python 字符串
- Python字符串
- Python字符串
- python字符串
- Python 字符串
- python 字符串
- Python 字符串
- Python字符串
- python 字符串
- Educational Codeforces Round 34 (Rated for Div. 2) A-C 题解
- 菜鸟学python(04) —— 基础笔记整理
- SSL P1520 牛的RP 题目
- java--jvm--目录
- 171218---LAMP介绍之php安装
- python字符串
- 硬件体系优化及IO优化核心优化原理(学习老男孩视频23期)体会
- SqlServer XML 类型数据操作
- 如何在Xcode上彻底修改iOS工程名
- 常见的计算机专业相关词汇汇总
- SVN
- Robust Systems Lab
- 懒汉式单例模式和饿汉式单例模式的详解
- angular根据按钮点击事件模糊查询