前言python
先學學基礎的python,萬事開頭難!仍是好好學學開發吧!dom
直接上乾貨ide
#coding:utf8函數
s=input('請輸入一個年份:')學習
s=int(s)3d
year=Falseblog
if s % 100 ==0 and % 400 ==0:遊戲
year=True圖片
elif s % 100 !=0 and s % 4 ==0:開發
if year:
pirnt('閏年')
else:
print('平年')
Python運算函數
#coding:utf8
lsl=input('輸入成績')
if lsl==100:
print('好樣的你是最棒的')
elif lsl > 90:
print('怎麼搞的!')
elif lsl >80:
print('上課沒有認真聽講吧!')
elif lsl >70:
print('該努力學習了!')
elif lsl >60:
print('將及格找打了吧?')
總結! 積累點滴!
python猜數字遊戲
#coding:utf8
import random,time
secret=random randint(1,99)
guess=0
tries=0
print '一塊兒來玩猜數字遊戲吧!'
print '要猜的數字在1到100之間,我會給你10次機會'
while guess != secret and tries <10:
guess = input(「你猜它是什麼」)
if guess < secret:
print '過小了'
elif guess > secret;
print '太大了'
tries = tries + 1
if guess == secret:
print '哈哈你猜對了'
time.sleep(2)
else:
print 「你這個二百五,這都猜不對!正確答案是:",secret,"!"
time.sleep(2)