ex4.py
# -*- coding:utf-8 -*- #添加UTF-8编码 cars = 100 #变量cars有100辆 space_in_a_car = 4.0 #变量1辆车的空间可以容纳4个人 drives = 30# 变量司机有30名 passengers = 90 #乘客有90名 cars_not_driven = cars - drives #不开的车辆 cars_driven = drives#开车的数量=司机的数量 carpool_capacity = cars_driven * space_in_a_car #车辆运载能力=开车的数量乘以每辆车的容纳人数 average_passengers_per_car = passengers / cars_driven #平均每辆车乘坐的乘客数量=总乘客数除以开动的车辆数量 print ("there are",cars,"cars availale.") print ("there are only",drives,"drives availale.") print ("there will be",cars_not_driven,"enpty 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.')