1 Star 0 Fork 0

lhjlzf / Learn Python The Hard Way Note

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
ex4.py 965 Bytes
一键复制 编辑 原始数据 按行查看 历史
# _*_ coding: utf-8 _*_
# 有 100 辆车
cars = 100
# 每辆车上可以作 4 个人
space_in_a_car = 4.0
# 有 30 个司机
drivers = 30
# 有 90 个乘客
passengers = 90
# 不能开的车数 = 总车数 - 司机数
cars_not_driven = cars - drivers
# 可以开的车数 = 司机数
cars_driven = drivers
# 最多可以乘坐的人数 = 可以开的车数 * 每辆车上可以坐的人数
carpool_capacity = cars_driven * space_in_a_car
# 平均每辆车上的乘客 = 总乘客数 / 可以开的车数 (这里使用 // 是为了保证结果为整数)
average_passengers_per_car = passengers // cars_driven
print ("There are", cars, "cars available.")
print ("There are only", drivers, "drivers available.")
print ("There will be", cars_not_driven, "empty cars today.")
print ("We can transport", carpool_capacity,"people today.")
print ("We have", passengers, "to carpool today.")
print ("We need to put about", average_passengers_per_car, "in each car.")
Python
1
https://gitee.com/lhjzf/Learn-Python-The-Hard-Way-Note.git
git@gitee.com:lhjzf/Learn-Python-The-Hard-Way-Note.git
lhjzf
Learn-Python-The-Hard-Way-Note
Learn Python The Hard Way Note
master

搜索帮助