m = int(input())
if 20<=m and m<=100:
for i in range(11,m):
m += i
print("sum = "+str(m))
else:
print("error")
================================================================
x = float(input())
if x == 0:
y = x
else:
y = 1/x
print("f({:.1f}) = {:.1f}".format(x,y))
================================================================
a, n = input().split()
plus = 0
n = int(n)
for n in range(1, n+1):
an = int(n * a)
n += 1
plus += an
print("s = {}".format(plus))
================================================================
N = int(input())
plus = 0
for i in range(1, N*2, 2):
P = 1/i
plus += P
i += 1
print("sum = {:.6f}".format(plus))
================================================================
N = int(input())
plus = 0
for i in range(1, N+1, 2):
P = i/(2*i-1)
plus += P
i += 1
for i in range(2, N+1, 2):
Q = i/(2*i - 1)
plus -= Q
i += 1
print("{:.3f}".format(plus))
================================================================
A, B = input().split(",") # 以逗号作为两个参数的分隔符
B = int(B.strip(' ')) # 将A、B前后的空格符去掉
A = A.strip(' ')
AB = B * A
print(int(AB))
================================================================
A, B = input().split(",") # 逗号分隔数值和进制
B = int(B) # 转换公式:int('A',B)
print(int(A, B)) # 所以B需是整型,A需是字符串
↓ | 2进制 | 8进制 | 10进制 | 16进制 |
2进制 | - | bin(int(x, 8)) | bin(int(x, 10)) | bin(int(x, 16)) |
8进制 | oct(int(x, 2)) | - | oct(int(x, 10)) | oct(int(x, 16)) |
10进制 | int(x, 2) | int(x, 8) | - | int(x, 16) |
16进制 | hex(int(x, 2)) | hex(int(x, 8)) | hex(int(x, 10)) | - |
================================================================
# 数学思路
A, B, C = input().split(" ")
A, B, C = int(A), int(B), int(C)
a = max(A, B, C)
c = min(A, B, C)
b = A + B + C - a - c
a, b, c = str(a), str(b), str(c)
d = '->'
all = d.join((c, b, a))
print(all)
# 转换成整型放入列表排序后取出
# 本以为不用转整型,列表有内建的排序方式
# 但如果有负数,排序就与正常的不一致
# 所以仍需要先转为整型再转回字符串进行拼接
A, B, C = input().split(" ")
A, B, C = int(A), int(B), int(C)
R = sorted([A, B, C])
R[0], R[1], R[2] = str(R[0]), str(R[1]), str(R[2])
print("->".join((R[0], R[1], R[2])))
================================================================
lower, upper = input().split(" ")
if int(lower) <= int(upper) <= 100:
print("fahr celsius")
for i in range(int(lower), int(upper) + 1, 2):
C = 5 * (i - 32) / 9
print("{}".format(i) + "{:>{}.1f}".format(C, 6))
else:
print("Invalid.")
================================================================
m, n = input().split()
m = int(m)
n = int(n)
sum = 0
for m in range(m, n+1):
S = pow(m, 2) + pow(m, -1)
sum += S
print("sum = {:.6f}".format(sum))
================================================================
a, b, c = input().split()
a = int(a)
b = int(b)
c = int(c)
s = (a + b + c)/2
area = pow(s*(s-a)*(s-b)*(s-c), 1/2)
L = a + b + c
if (a+b) > c and (a+c) > b and (b+c) > a:
print("area = {:.2f}; perimeter = {:.2f}".format(area, L))
else:
print("These sides do not correspond to a valid triangle")
================================================================
A, B = input().split()
A, B = int(A), int(B)
Sum = 0
i = 0
for A in range(A, B+1):
i += 1
if i % 5 == 0 or A == B:
print("{:>5d}".format(A))
else:
print("{:>5d}".format(A), end='')
Sum += A
print("Sum = {}".format(Sum))