返回列表 發帖

七則運算

  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=%d,b=%d時..."%(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,b=7,3
  2. print("當a=%d,b=%d時..."%(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))
複製代碼

TOP

  1. a,b=7,3
  2. print('當a=%d,b=%d時...'%(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))
複製代碼

TOP

  1. a=7,b=3
  2. print("當a=%d,b=%d時..."%(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))
複製代碼

TOP

  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))
複製代碼

TOP

  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))
複製代碼

TOP

  1. a,b=7,3
  2. print("當a=%d,b=%d時..."%(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))
複製代碼

TOP

本帖最後由 楊書華 於 2020-7-27 14:03 編輯
  1. a,b=7,3
  2. print("當a等於"+str(a)+"且b等於"+str(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等於"+str(a//b)+"餘"+str(a%b))
  8. print("a的b次方等於"+str(a**b))
複製代碼
._.

TOP

  1. a=7,b=3
  2. print("當=%d,b=%d時..."%(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)
複製代碼

TOP

  1. a,b=7,3
  2. print("當a=%d,b=%d時..."%(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)")
複製代碼

TOP

  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))
複製代碼

TOP

本帖最後由 林家代 於 2020-7-27 14:47 編輯
  1. a,b=7,3
  2. print("當a=%d,b=%d時..."%(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))
複製代碼

TOP

a=7
b=3
print("當a="+str(a)+",b="+str(b)+"時...")
print("a+b="+str(a+b))
print("a-b="+str(a-b))
print("a*b="+str(a*b))
print("a/b="+str(a/b))
print("a%b="+str(a%b))   
print("a//b="+str(a//b))
print("a**b="+str(a**b))

TOP

  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))
複製代碼

TOP

  1. a,b=7,3
  2. print("當a=%d,b=%d時..."%(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))
  10. print("a**b={}".format(a**b))
複製代碼

TOP

  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))
複製代碼

TOP

  1. a,b=7,3
  2. print("當a="+str(a)+",b="+str(b)+"時...")
  3. print("a+b="+str(a+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))
複製代碼

TOP

  1. a=int(input("a="))
  2. b=int(input("b="))
  3. c=int(input("c="))
  4. sum=a+b+c
  5. avg=sum/3
  6. print("total:%d average:%2f"%(sum,avg))
複製代碼

TOP

返回列表