【Python】【Jupyter】Jupyter 的簡單使用 與 Python的基本輸出輸入


long cut picture

上課無聊寫着玩的,不必當真。

Jupyter 的簡單使用 與 Python的基本輸出輸入

print("本節課由 余布洛夫斯基 友情授課 | 由 萌狼藍天 友情上演")
本節課由 余布洛夫斯基 友情授課 | 由 萌狼藍天 友情上演
  • Jupyter 有兩種模式,第一種是命令模式(按下ESC進入命令模式),第二種是編輯模式(按下Enter進入編輯模式)
  • 在命令模式下,按A在當前單元格上方插入一個單元格,按B在當前單元下方插入一個單元格
  • 按下Shift+Enter將會執行當前單元格內容,並且新建一個單元格。
  • 如果你想知道更多快捷鍵,應該嘗試在命令模式下按下 H

數據准備

  • 在命令模式下,按下L可以顯示或者隱藏單元格內的行號
  • 在命令模式下,按下Y單元格變成代碼塊,按下M變成Markdown編輯器,這是我最常用的

(以下數據隨便寫,無所謂的。)

number=520
price=99.9
result = number * price

輸出

print("金額:{:.2f}".format(result))
金額:51948.00
print("金額:"+repr(result)+"元")
金額:51948.0元

輸入

str=input('請問你今天要來點兔子嗎?')
請問你今天要來點兔子嗎?yes

一些練習

num = input("請輸入購買數量:")
請輸入購買數量:800
  商品編碼              圖書名稱              數量     商品金額  
print("———————————————————————————————")
# 表頭
print(chr(9615),end="")
print("{:^6s}".format("商品編碼"),end="")
print(" | ",end="")
print("{:^17s}".format("圖書名稱"),end="")
print(" | ",end="")
print("{:^6s}".format("數量"),end="")
print(" | ",end="")
print("{:^7s}".format("商品金額"),end="")
print(chr(9615))
# 分割線
print("———————————————————————————————")
print(chr(9615),end="")
print("{:^10s}".format("0100096543"),end="")
print(" | ",end="")
print("{:^21s}".format("Samll Yellow Book"),end="")
print(" | ",end="")
print("{:^8d}".format(int(num)),end="")
print(" | ",end="")
print("{:^11.2f}".format(9.99),end="")
print(chr(9615))
print("———————————————————————————————")
———————————————————————————————
▏ 商品編碼  |       圖書名稱        |   數量   |  商品金額  ▏
———————————————————————————————
▏0100096543 |   Samll Yellow Book   |   800    |    9.99    ▏
———————————————————————————————

(說實話)我認為上面的輸入真是糟糕的、麻煩的輸出方式

print("———————————————————————————————————————")
# 表頭
print(chr(9615),end="")
print(" {}\t".format("商品編碼"),end="")
print(" | ",end="")
print(" {}\t\t".format("圖書名稱"),end="")
print(" | ",end="")
print(" {}\t".format("數量"),end="")
print(" | ",end="")
print(" {}\t ".format("商品金額"),end="")
print(chr(9615))
# 分割線
print("———————————————————————————————————————")
print(chr(9615),end="")
print(" {}\t".format("0100096543"),end="")
print(" | ",end="")
print(" {}\t".format("Samll Yellow Book"),end="")
print(" | ",end="")
print("{:^d}\t\t".format(int(num)),end="")
print(" | ",end="")
print("{:^.2f}\t\t".format(9.9),end="")
print(chr(9615))
print("———————————————————————————————————————")
———————————————————————————————————————
▏ 商品編碼	 |  圖書名稱		 |  數量	 |  商品金額	 ▏
———————————————————————————————————————
▏ 0100096543	 |  Samll Yellow Book	 | 800		 | 9.90		▏
———————————————————————————————————————

2022年3月22日 萌狼藍天


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM