Created
August 3, 2011 08:43
-
-
Save adaptives/1122196 to your computer and use it in GitHub Desktop.
Exercise 4
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #Define a variable called cars and give it the integer value 100 | |
| cars = 100 | |
| #Define a variable called space_in_a_car a nd give it the floating point value 4.0 | |
| space_in_a_car = 4.0 | |
| #Define a variable called drivers, and give it the integer value 30 | |
| drivers = 30 | |
| #Define a variable called passengers, and give it the integer value 90 | |
| passengers = 90 | |
| #Define a variable called cars_not_driven, and compute it as the difference between cars and drivers | |
| cars_not_driven = cars - drivers | |
| #Define a variable called cars_driven and assign to it the value of the variable drivers | |
| cars_driven = drivers | |
| #Define a variable called carpool_capacity and compute it as the product of the values of variables, cars_driven and space_in_a_car | |
| carpool_capacity = cars_driven * space_in_a_car | |
| #Define a variable called average_passengers_per_car and compute it as passengers divided by cars_driven | |
| average_passengers_per_car = passengers / cars_driven | |
| #print the number of cars available | |
| print "There are", cars, "cars available." | |
| #print the number of drivers available | |
| print "There are only", drivers, "drivers available." | |
| #print the number of empty cars today | |
| print "There will be", cars_not_driven, "empty cars today." | |
| #print the number of people we can transport today | |
| print "We can transport", carpool_capacity, "people today." | |
| #print the number of passengers we have for carpooling today | |
| print "We have", passengers, "to carpool today." | |
| #print the average passengers we can place per car | |
| print "We need to put about", average_passengers_per_car, "in each car." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment