浙大版《Python程序设计》题目集
作者:互联网
sum = 0
start = 11
end = eval(input())
for i in range(start,end+1):
sum = sum + i
print("sum =",sum)
num = eval(input())
if num == 0:
num = format(num,'.1f')
print("f(",num,") = ",num,sep = '')
else:
res = 1.0/num
num = format(num,'.1f')
print("f(",num,") = ",format(res,'.1f'),sep = '')
power_consumption = eval(input())
if power_consumption < 0:
print("Invalid Value!")
else:
if power_consumption <= 50:
cost = 0.53*power_consumption
else:
cost = 0.53*50+(power_consumption-50)*(0.53+0.05)
print("cost = ",format(cost,'.2f'),sep = '')
a,n = map(int,input().split(" "))
sum = 0
for i in range(n):
res = a*(pow(10,i)*(n-i))
sum = sum + res
print("s = ",sum,sep = '')
num = eval(input())
sum = 0
count = 1
for i in range(num):
sum = sum + 1/count
count = count + 2
print("sum = ",format(sum,'.6f'),sep = '')
num = eval(input())
sum = 0
count = 1
for i in range(num):
if count % 2 == 0:
sum = sum - count/(2*count - 1)
else:
sum = sum + count/(2*count - 1)
count = count + 1
print(format(sum,'.3f'))
A,B = map(int,input().split(","))
A = str(A)
A = A*B
print(int(A))
a,b = map(int,input().split(","))
if b == 2:
res = int(str(a),2)
elif b == 8:
res = int(str(a),8)
elif b == 16:
res = int(str(a),16)
print(res)
a,b,c = map(int,input().split(" "))
list = [a,b,c]
list.sort()
print(list[0],"->",list[1],"->",list[2],sep = "")
lower,higher = map(int,input().split(" "))
if lower <= higher and lower <= 100 and higher <= 100:
print("fahr celsius")
i = lower
while i <= higher:
c = 5*(i - 32)/9
print(i,format(c,'>6.1f'))
i = i + 2
else:
print("Invalid.")
m,n = map(int,input().split(" "))
sum = 0
start = m
end = n
while start <= end:
sum = sum + 1/start + pow(start,2)
start = start + 1
print("sum = ",format(sum,".6f"))
a,b,c = map(int,input().split(" "))
s = (a + b + c)/2
if a + b > c and a + c > b and b + c > a:
area = pow(s * (s - a) * (s - b) * (s - c),1/2)
perimeter = a + b + c
print("area = ",format(area,".2f"),";perimeter = ",format(perimeter,".2f"),sep = "")
else:
print("These sides do not correspond to a valid triangle")
water_consumption = eval(input())
if water_consumption <= 15:
cost = (4*water_consumption)/3
print(format(cost,".2f"))
else:
cost = 2.5 * water_consumption - 17.5
print(format(cost,".2f"))
a,b = map(int,input().split(" "))
sum = 0
count = 0
for i in range(a,b + 1):
print(format(i,">5"),end = "")
count = count + 1
sum = sum + i
if count % 5 == 0:
print("\n")
if count % 5 == 0:
print("Sum = ",sum)
else:
print("\n")
print("Sum = ",sum)
标签:count,Python,sum,浙大,int,num,input,print,程序设计 来源: https://www.cnblogs.com/centimeter73/p/15463462.html