# Variables cars = 100 # Number of cars. space_in_a_car = 4.0 # Number of people that can fit in a car. drivers = 30 # Number of people who can drive a car. passengers = 90 # Amount of passengers needing to be transported cars_not_driven = cars - drivers # Calculates aundrivable cars. cars_driven = drivers # States that the number of drivers is equal to the number of cars. carpool_capacity = cars_driven * space_in_a_car # Calculates carpool. passengers_per_car = passengers / cars_driven # Calculates the average number of passengers per car. #Output print "There are", cars, "cars available," print "But there only", drivers, "drivers available." print "So there will be", cars_not_driven, "empty cars." print "A maximum of", carpool_capacity, "people can be driven today." print passengers, "people need to be transported." print "An average of", passengers_per_car, "people can fit in each car."
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question