###### Assignment 4 ###### ###### Alrik Olson ###### ## Chapter 5 ## Prog Assign 5 initTuition = 6000 for x in range(0, 5): initTuition *= 1.02 print("The increased tuition is: $" + str(initTuition)) ## Chapter 5 ## Prog Assign 6 speed = int(input("Enter vehicle speed: \n")) hours = int(input("Enter number of hours spent traveling: \n")) print("Hour Distance Traveled") print("___________________________________") for x in range(0, hours + 1): if(x == 0): continue distance = speed * x print(" " + str(x) + " " + str(distance) + " ") ## Chapter 4 ## Prog Assign 7 months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"] inches = 0 years = int(input("Enter years: \n")) totalMonths = years * 12 for x in range(0, years): for y in range(0, 12): inches += int(input("Enter inches of rainfall for " + months[y] + ": \n")) avgRainfall = inches / totalMonths print("Total months in period: " + str(totalMonths)) print("Total inches of rainfall: " + str(inches)) print("Average inches of rainfall per month: " + str(avgRainfall)) ## Chapter 4 ## Prog Assign 12 number = int(input("Enter a non-negative number: \n")) output = number for x in range(output, 1, -1): multiple = x - 1 if(multiple < 1): break output *= multiple print(str(number) + "! is " + str(output))
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