Python 文宇

km = eval(input("输入里程数:"))
if km < 3 and km >0:
    money = 7
elif km < 8:
    money = 7 + 1.7 * (km - 3)
else:
    money = 7 + (8-3) * 1.7 + (km - 8) * 2
print(money)
"""向上、向下取整"""
import math
print(math.ceil(4.3))
print(math.floor(4.3))
import math
km = eval(input("输入里程数:"))
if km < 3 and km >0:
    money = 7
elif km < 8:
    money = 7 + 1.7 * math.ceil(km - 3)
else:
    money = 7 + (8-3) * 1.7 + math.ceil(km - 8) * 2
print(money)
"""while循环"""
i = 3
while i < 10:
    print("hello")
    i += 1
print("循环结束")
"""一加到一百,while循环"""
i = sum = 0
while i <= 100:
    sum += i
    i += 1
print("一加到一百结果为:", sum)
"""输出一到一百的偶数"""
i = 0
while i <=100:
    i += 1
    if i % 2 == 0:
        print(i, end=" ")
"""for循环"""
for i in "python":
    print(i)
score = [29, 34, 90, 87, 23]
for i in score:
    if i >= 60:
        print(i, "及格")
    else:
        print(i, "不及格")
"""for循环内置函数
range([开始值,] [结束值,] [步长])"""
for i in range(1, 101, 5):
    print(i, end=" ")

发表评论

您的电子邮箱地址不会被公开。 必填项已用 * 标注