python練習
!/usr/bin/python
–– coding: UTF-8 ––
for i in range(1,5):
for j in range(1,5):
for k in range(1,5):
if( i != k ) and (i != j) and (j != k):
print i,j,k
!/usr/bin/python
coding=utf-8
year=int(raw_input(`year:
`))
month = int(raw_input(`month:
`))
day = int(raw_input(`day:
`))
!/usr/bin/python
–– coding: UTF-8 ––
year = int(raw_input(`year:
`))
month = int(raw_input(`month:
`))
day = int(raw_input(`day:
`))
months = (0,31,59,90,120,151,181,212,243,273,304,334)
if 0 < month <= 12:
sum = months[month – 1]
else:
print `data error`
sum += day
leap = 0
if (year % 400 == 0) or ((year % 4 == 0) and (year % 100 != 0)):
leap = 1
if (leap == 1) and (month > 2):
sum += 1
print `it is the %dth day.` % sum
!/usr/bin/python
–– coding: UTF-8 ––
l = []
for i in range(3):
x = int(raw_input(`integer:
`))
l.append(x)
l.sort()
print l
!/usr/bin/python
–– coding: UTF-8 ––
def fib(n):
a,b = 1,1
for i in range(n-1):
a,b = b,a+b
return a
輸出了第10個斐波那契數列
print fib(10)
列表複製
!/usr/bin/python
–– coding: UTF-8 ––
a = [1, 2, 3]
b = a[:]
print b
!/usr/bin/python
–– coding: UTF-8 ––
for i in range(1, 10):
print
for j in range(1, i+1):
print “%d%d=%d” % (i, j, ij),
time.strftime(`%Y%m%d%H%M%S`,time.localtime(time.time()))
!/usr/bin/python
–– coding: UTF-8 ––
for n in range(100,1000):
i = n / 100
j = n / 10 % 10
k = n % 10
if n == i ** 3 + j ** 3 + k ** 3:
print n
!/usr/bin/python
–– coding: UTF-8 ––
import datetime
if name == `main`:
# 輸出今日日期,格式為 dd/mm/yyyy。更多選項可以檢視 strftime() 方法
print(datetime.date.today().strftime(`%d/%m/%Y`))
# 建立日期物件
miyazakiBirthDate = datetime.date(1941, 1, 5)
print(miyazakiBirthDate.strftime(`%d/%m/%Y`))
# 日期算術運算
miyazakiBirthNextDay = miyazakiBirthDate + datetime.timedelta(days=1)
print(miyazakiBirthNextDay.strftime(`%d/%m/%Y`))
# 日期替換
miyazakiFirstBirthday = miyazakiBirthDate.replace(year=miyazakiBirthDate.year + 1)
print(miyazakiFirstBirthday.strftime(`%d/%m/%Y`))
相關文章
- 新手練習:Python練習題目Python
- 【Python】python練習Python
- python 練習0000Python
- Python 練習題Python
- python練習小結Python
- Python 作業練習Python
- python練習題解析Python
- Python學習-while迴圈練習PythonWhile
- Python基礎練習題Python
- 五、python的練習題Python
- Python指令碼練習一Python指令碼
- Python 程式設計練習Python程式設計
- Python函式練習題Python函式
- python相關練習題Python
- python練習冊-第0000題Python
- python指令碼練習筆記Python指令碼筆記
- python 檔案讀寫練習Python
- Python 小練習 剔除奇數Python
- python 實現課堂練習Python
- python matplot繪圖工具練習Python繪圖
- Python-100 練習題 02Python
- python物件導向練習題01Python物件
- python-購物車程式練習Python
- 05python的相關練習Python
- python練習冊-第0002題Python
- python基礎語句小練習Python
- python006 列表練習題Python
- Python練習題篇(列表、字典、元祖)Python
- 9道python基礎練習題Python
- python基礎 while迴圈練習PythonWhile
- python 基礎之scrapy 原理練習Python
- Python練習01-對戰小遊戲Python遊戲
- 慕課網Python入門練習題---Python
- python練習 2020/10/13Python
- python 100題練習記錄(三)Python
- Python 小甲魚教程 課後練習42Python
- 練習maya python API jointChain中文標註PythonAPIAI
- 練習安裝Python擴充套件庫Python套件