Python练习题
来源:互联网 发布:ubuntu没有 ssh目录 编辑:程序博客网 时间:2024/05/16 01:22
7一年中几月几日算多少天
y=int(raw_input("y/n"))m=int(raw_input("m/n"))d=int(raw_input("d/n"))shu=(0,31,59,90,120,151,181,212,243,273,304,334)if 0<m<=12 : i=m-1 sum=shu[i]+delse: print"error"leep=0if(y%400==0 or y%4==0 and y%100!=0): leep=1if(leep==1 and m>2): sum=sum+1print 'it is the %dth day.' % sum
9 暂停一秒输出。
import timea=[1,2,3,5,6]for i in a: print i time.sleep(1)b={'a':1,'b':2,'c':3,'d':6,'k':8}for key in b: print key for key,value in dict.items(b): print key ,value time.sleep(0.1)
10本地实时时间
import timeprint time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(time.time()))# 暂停一秒time.sleep(1)print time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(time.time()))
11古典问题:有一对兔子,从出生后第3个月起每个月都生一对兔子,小兔子长到第三个月后每个月又生一对兔子,假如兔子都不死,问每个月的兔子总数为多少?
def fib(n): if n==1 or n==2: return 1 return fib(n-2)+fib(n-1)for i in range(1,42): print '%12ld ' % (fib(i)), if i%6==0: print''
0 0
- Python 练习题
- python 练习题
- python 练习题
- python练习题
- Python练习题
- Python练习题
- Python练习题
- python练习题
- Python练习题
- Python练习题
- python练习题
- Python练习题
- python练习题
- python练习题!
- Python练习题
- python练习题
- Python练习题
- python练习题
- 山东理工大学 链表练习题答案
- java中<> 的用法
- HTML+CSS基础 img标签border参数变化产生的效果
- CGLib、Proxy、Aop resources
- 关于pscp的人生经验
- Python练习题
- 简单有效的养生方法
- Linux中的文件描述符与打开文件之间的关系
- Kinect v2 简介
- 深入理解Java:注解(Annotation)基本概念
- 设计模式之禅——策略模式
- Python学习笔记- 廖雪峰教程【python 2】//为继续学习爬虫准备-02 [待完善]
- HTML+CSS基础 img标签border给显示的图片加上一个黑色边框
- 深入理解Java:注解(Annotation)自定义注解入门