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 練習0000Python
- Python 練習題Python
- python練習題解析Python
- Python 作業練習Python
- python練習小結Python
- Python學習-while迴圈練習PythonWhile
- Python函式練習題Python函式
- python相關練習題Python
- python練習 2020/10/13Python
- Python基礎練習題Python
- 五、python的練習題Python
- python 實現課堂練習Python
- python matplot繪圖工具練習Python繪圖
- python指令碼練習筆記Python指令碼筆記
- python006 列表練習題Python
- Python-100 練習題 02Python
- python練習冊-第0000題Python
- python練習冊-第0002題Python
- python 基礎之scrapy 原理練習Python
- python基礎 while迴圈練習PythonWhile
- python物件導向練習題01Python物件
- Python練習題篇(列表、字典、元祖)Python
- python 100題練習記錄(三)Python
- python基礎語句小練習Python
- 9道python基礎練習題Python
- python-購物車程式練習Python
- 05python的相關練習Python
- 練習安裝Python擴充套件庫Python套件
- python基礎(四)----列表、字典練習題Python
- 慕課網Python入門練習題---Python
- markdown 使用練習練習
- 240個Python練習案例附原始碼(百看不如一練)Python原始碼
- Python練習01-對戰小遊戲Python遊戲
- python第一節課內容及練習Python
- Python3 (基礎練習)猴子吃桃Python
- 基礎練習——python特殊的數字——2020.11.17Python
- python實現資料分頁小練習Python