输入一个正整数m(20<=m<=100),计算 11+12+13+…+m 的值。
输入格式:
在一行输入一个正整数m。
输出格式:
在一行中按照格式“sum = S”输出对应的和S.
输入样例:
在这里给出一组输入。例如:
输出样例:
在这里给出相应的输出。例如:
m=int(input())
sum=0
for i in range(11,m+1):
sum+=i
print("sum = %d"%sum)
x=input()
if float(x) != float(0):
print("f(%.1f) = %.1f"%(float(x),1/float(x)))
else:
print("f(0.0) = 0.0")
a=int(input())
if a > 50 :
print("cost = %.2f"%((a-50)*0.58+50*0.53))
elif a >= 0 and a <= 50:
print("cost = %.2f"%(a*0.53))
else:
print("Invalid Value!")
a=int(input())
s=0
for i in range(1,a+1):
b = 1/(2*i-1)
s+=b
print("sum = %.6f"%s)
n=int(input())
s=0
for i in range(1,n+1):
if i % 2 == 0:
s-=i/(2*i-1)
else:
s+=i/(2*i-1)
print("%.3f"%s)
s=input()
a,b=s.split(",")
a.replace(' ','')
b.replace(' ','')
a=int(a)
b=int(b)
print(("%d"%a)*b)
s=input()
a,b=s.split(",")
b=int(b)
print(int(a,b))
s=input()
data=[]
a,b,c=s.split(" ")
data=[a,b,c]
for i in range(len(data)):
data[i]=int(data[i])
for i in range(len(data)):
for j in range(i,len(data)):
if data[i] > data[j] :
data[i],data[j]=data[j],data[i]
print("%d->%d->%d"%(data[0],data[1],data[2]))
s=input()
lower,upper=s.split(" ")
lower=int(lower)
upper=int(upper)
if lower <= upper and upper <= 100:
print("fahr celsius")
for i in range(lower,upper+1,2):
print("%d%6.1f"%(i,(5*(i-32)/9)))
else:
print("Invalid.")
s=input()
m,n=s.split(" ")
m=int(m)
n=int(n)
s=0
for i in range(m,n+1):
s+=i**2+1/i
print("sum = %.6f"%s)
s=input()
a,n=s.split(" ")
n=int(n)
b=""
s=0
for i in range(2,n+1,2):
b=a*i
b=int(b)
s+=b
print(s)
import math
s=input()
a,b,c=s.split(" ")
a=int(a)
b=int(b)
c=int(c)
d=(a+b+c)/2
if (a + b) > c and (a + c) > b and (b + c) > a:
area = math.sqrt(d*(d-a)*(d-b)*(d-c))
perimeter = d*2
print("area = %.2f; perimeter = %.2f"%(area,perimeter))
else:
print("These sides do not correspond to a valid triangle")
import math
x=int(input())
y=0
if x <=15 :
y=4*x/3
else:
y=2.5*x-17.5
print("%.2f"%y)
s=input()
a,b=s.split(" ")
a=int(a)
b=int(b)
sum=0
count=0
if a in range(-100,b+1) and b in range(a,101):
for i in range(a,b+1):
sum+=i
count+=1
if count % 5 != 0 :
print("%5d"%i,end="")
else:
print("%5d"%i)
if i == b and count % 5 !=0:
print()
print("Sum = %d"%sum)