幾個簡單的Python小程序

判斷自己當前是否是白富美

color=input("你白嗎?") #白 或者 黃
money=int(input("請輸入你的財產總和:")) #輸入1000
beautiful=input("你美麼?") #美 或者 普通
# if 白 並且 富 並且 美:
# if 白 and 富 and 美:
if color=="白" and money>1000 and beautiful=="美":
  print("白富美..........已經到了人生巔峯")
else:
  print("革命尚未成功,仍需努力,人生沒有捷徑")
import time
time.sleep(15)    

製作一個簡單的文本進度條:

import time
scale=50
print("執行開始".center(scale//2,"."))
start=time.perf_counter()
for i in range(scale+1):
  a='*' * i
  b='.' * (scale-i)
  c=(i/scale)*100
  dur=time.perf_counter()-start
  print("\r{:^3.0f}%[{}->{}]{:.2f}s".format(c,a,b,dur),end='')
  time.sleep(0.2)
print("\n"+"執行結束".center(scale//2,'.'))
  


目前水平有限,還寫不出高質量的代碼,希望繼續努力,寫出更高質量的代碼。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章