cars = 100# represents the total number of cars space_in_a_car = 4.0 #underscores are used to put "imaginary" spaces in variable names #it was not necessary to use a float in 4 as the final result is not a fraction regardless of whether ints or floats are used #the only difference if a float is used is that there will be a ".0" after the final result of 120 drivers = 30# number of drivers available passengers = 90# number of people that need to be transported cars_not_driven = cars - drivers# cars that won't be used due to a lack of drivers cars_driven = drivers# only one driver per car possible carpool_capacity = cars_driven * space_in_a_car# the total number of available seats average_passengers_per_car = passengers / cars_driven# the average number of people in each car #the following lines display the numbers on screen surrounded by actual words print "There are", cars, "cars available." #number of cars available print "There are only", drivers, "drivers available." #number of drivers present print "There will be", cars_not_driven, "empty cars today." #number of cars that can't be driven print "We can transport", carpool_capacity, "people today." #total number of people that can be transported print "We have", passengers, "to carpool today." #the total number of passengers print "We need to put about", average_passengers_per_car, "in each car." #the number of passengers that will be placed in each car #study drills: #assuming all other parts of the program remained the same, the compiler #was unable to locate car_pool_capacity as carpool_capacity was the variable #actually used #floating point numbers are the way in which numbers are stored on computer in order to avoid being limited by a fixed number of digits
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