今天是30天程式語言研究的第六天,研究的語言一樣是python,今天主要學習的是建立一個計算機和字典的部分
網址:https://www.youtube.com/watch?v=zdMUJJKFdsU&ab_channel=GrandmaCan-%E6%88%91%E9%98%BF%E5%AC%A4%E9%83%BD%E6%9C%83
筆記:
num1 = float(input("請輸入第一個數: "))
op = input("請輸入運算符號: ")
num2 = float(input("請輸入第二個數: "))
if op == "+":
print(num1+num2)
elif op == "-":
print(num1-num2)
elif op == "":
print(num1num2)
elif op == "/":
print(num1/num2)
else:
print("不支援的運算")
dic = { "蘋果":"apple", "香蕉":"banana", "貓":"cat", "狗":"dog"}
dic1 = { 1:"apple", 2:"banana", 3:"cat", 4:"dog"}
print(dic["貓"])
print(dic1[1])