返回列表 發帖

計算總和 (一)

計算 1+2+3+…+10 之和

  1. sum=0
  2. for i in range(1,11):
  3.     sum+=i
  4. print("1+2+3+...+10=%d"%sum)
複製代碼
  1. sum=0
  2. for i in range(1,11):
  3.     sum+=i   #sum=sum+i
  4. print("1+2+3+...+10={}".format(sum))
複製代碼

  1. sum=0
  2. for i in range(1,11,1):
  3.     sum=sum+i
  4. print(sum)
複製代碼

TOP

  1. sum=0
  2. for i in range(1,11):
  3.     sum=sum+i
  4. print("1+2+3+4+5+6+7+8+9+10=",sum)
複製代碼

TOP

sum=0
for i in range(1,11,1):
    sum=sum+i
print(sum)

TOP

sum=0
for i in range(1,11,1):
    sum=sum+i
print(sum)

TOP

  1. sum=0
  2. for i in range (1,100,1):
  3.     sum=sum+i
  4. print(sum)
複製代碼

TOP

5

TOP

sum=0
for i in range(1,11,1):
    sum=sum+i
    print(sum)

TOP

--

TOP

  1. sum=0
  2. for i in range(1,11):
  3.     sum+=i
  4. print(i)
複製代碼

TOP

  1. s=0
  2. for i in range(1,11):
  3.     s=s+1
  4.     print(s)
  5.    
複製代碼

TOP

  1. s=0
  2. for i in range(1,11):
  3.    s=s+i
  4. print(s)
複製代碼

TOP

  1. s=0
  2. for i in range(1,11):
  3.     s=s+i
  4.     print(s)
複製代碼

TOP

  1. s=0
  2. for i in range(1,11):
  3.         s=s+i
  4.         print(s)
複製代碼

TOP

  1. for i in range(1,11,1):
  2.     s=s+i
  3. print(s)
複製代碼

TOP

  1. s=0
  2. for i in range(1,11):
  3.     s=s+i
  4. print(s)
複製代碼

TOP

  1. t=0
  2. for i in range(11):
  3.    t=t+i
  4. print(t)
複製代碼
Attention Seeker </3

TOP

  1. sum=0
  2. for i in range(1,11,1):
  3.     sum=sum+1
  4. print(sum)
複製代碼

TOP

  1. sum=0
  2. for i in range(1,11):
  3.     sum+=i
  4. print("1+2+3+...+10=%d"%sum)
複製代碼

TOP

返回列表