当前位置:   article > 正文

浙大python程序设计课后答案_从零开始学Python【浙大版《Python 程序设计》题目集】...

浙大python题库及答案

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)

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/不正经/article/detail/552789
推荐阅读
相关标签
  

闽ICP备14008679号