第4个python程序:变量

来源:互联网 发布:栅格数据 编辑:程序博客网 时间:2024/05/21 19:43
[root@mysql1 pshell]# cat ex4.py 
#!/usr/bin/env Python
#-*-coding:utf-8-*-


cars = 100
space_in_a_car = 4
drivers = 30
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 "three 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."
[root@mysql1 pshell]# python ex4.py 
there are 100 cars available.
there are only 30 drivers available.
three will be 70 empty cars today.
we can transport 120 people today.
we have 90 to carpool today.
we need to put about 3 in each car.
0 0
原创粉丝点击