赞
踩
a = int(input()) # 输入整数的格式
b = int(input())
print(a + b)
a, b, c = input().split() # split默认空格分割,返回的是字符串
a = int(a) # 转换为int
b = int(b)
c = int(c)
print(b * b - 4 * a * c)
每个数转换为int比较麻烦,也可以这样写:
# 用map将分割后的字符串类型转换为int类型
a, b, c = map(int, input().split())
print(b * b - 4 * a * c)
print("Python语言简单易学".encode("utf-8"))
m = int(input())
s = 0
for i in range(11, m + 1): # 左闭右开
s = s + i
print("sum = %d" % s) # 格式化输出
x = float(input()) # 输入实数的格式,python没有double类型!
if x == 0: # 不用打括号
print("f(0.0) = 0.0")
else:
print("f(%.1f) = %.1f" % (x, 1.0 / x))
x = float(input())
if x < 0:
print("Invalid Value!")
else:
if x <= 50:
cost = x * 0.53
else:
cost = 50 * 0.53 + (x - 50) * 0.58
print("cost = %.2f" % cost)
a, n = map(int, input().split())
s = 0
x = 0
for i in range(n):
x = x * 10 + a
s += x
print("s = %d" % s)
n = int(input())
s = 0
for i in range(1, n + 1):
t = 2 * i - 1
s += 1.0 / float(t)
print("sum = %.6f" % s)
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。