返回列表 發帖

七則運算

本帖最後由 鄭繼威 於 2022-7-18 14:42 編輯

  1. a=7
  2. b=3
  3. print("當a="+str(a)+",b="+str(b)+"時...")
  4. print("a+b="+str(a+b))
  5. print("a-b="+str(a-b))
  6. print("a*b="+str(a*b))
  7. print("a/b="+str(a/b))
  8. print("a%b="+str(a%b))    #取餘數
  9. print("a//b="+str(a//b))  #求商
  10. print("a**b="+str(a**b))  #指數運算
複製代碼
  1. a,b=7,3
  2. print("當a={},b={}時...".format(a,b))
  3. print("a+b={}".format(a+b))
  4. print("a-b={}".format(a-b))
  5. print("a*b={}".format(a*b))
  6. print("a/b={}".format(a/b))
  7. print("a%b={}".format(a%b))
  8. print("a//b={}".format(a//b))
  9. print("a**b={}".format(a**b))
複製代碼

  1. a=7
  2. b=3
  3. print(f"當a={a}時,b={b}時=")
  4. print(f"a+b={a+b}")
  5. print(f"a-b={a-b}")
  6. print("a*b={}".format(a*b))
  7. print("a/b=",a/b,sep="")
  8. print("a%b="+str(a%b))
  9. print(f"a//b={a//b}")
  10. print(f"a**b={a**b}")
複製代碼

TOP

  1. a,b=7,3
  2. print(f"當a={a},b={b}時")
  3. print(f"a+b={a+b}")
  4. print(f"a-b={a-b}")
  5. print(f"a*b={a*b}")
  6. print(f"a/b={a/b}")
  7. print(f"a%b={a%b}")
  8. print(f"a//b={a//b}")
  9. print(f"a**b={a**b}")
複製代碼

TOP

  1. a=7
  2. b=3
  3. print(f"當a={a},b={b}時")
  4. print(f"a+b={a+b}")
  5. print(f"a-b={a-b}")
  6. print(f"a*b={a*b}")
  7. print(f"a/b={a/b}")
  8. print(f"a%b={a%b}")
  9. print(f"a//b={a//b}")
  10. print(f"a**b={a**b}")
複製代碼

TOP

  1. # -*- coding: utf-8 -*-
  2. """
  3. Spyder Editor

  4. This is a temporary script file.
  5. """
  6. a=7
  7. b=3
  8. print(f"當a={a}時,b={b}時=")
  9. print(f"a+b={a+b}")
  10. print(f"a-b={a-b}")
  11. print(f"a*-b={a*b}")
  12. print(f"a/b={a/b}")
  13. print(f"a%b={a%b}")
  14. print(f"a//b={a//b}")
  15. print(f"a**b={a**b}")
複製代碼

TOP

  1. a=7
  2. b=3
  3. print(f"當a={a},b={b}時")
  4. print(f"a+b={a+b}")
  5. print(f"a-b={a-b}")
  6. print(f"a*b={a*b}")
  7. print(f"a%b={a%b}")
  8. print(f"a//b={a//b}")
  9. print(f"a**b={a**b}")
複製代碼

TOP

  1. a=7
  2. b=3
  3. print("當a={},b={}時...".format(a,b))
  4. print(f"a+b={a+b}")
  5. print(f"a-b={a-b}")
  6. print("a*b={}".format(a*b))
  7. print(f"a/b={a/b}")
  8. print("a%b="+str(a%b))
  9. print(f"a/b={a//b}")
  10. print(f"a**b={a**b}")
複製代碼

TOP

哈囉哈囉哈囉哈囉哈囉哈囉哈囉哈囉哈囉哈囉哈囉哈囉哈囉哈囉

TOP

返回列表