This** preview**
has intentionally

**sections.**

*blurred***to view the full version.**

*Sign up*
This** preview**
has intentionally

**sections.**

*blurred***to view the full version.**

*Sign up*
This** preview**
has intentionally

**sections.**

*blurred***to view the full version.**

*Sign up*
**Unformatted text preview: **intX -= 1 Loop Programming Exercises 7. Average Rainfall: def main(): years = int(input('Enter the number of years: ')) total_rainfall = 0.0 for a in range(years): for b in range(12): rainfall = float(input('Enter inches of rain for the month: ')) total_rainfall += rainfall months = years * 12 print('Number of months:', months) print('Total inches of rainfall:', total_rainfall) print('Average rainfall per month for entire period: ', format(total_rainfall / months, '.2f')) main() 9. Pennies for Pay: def main(): days = int(input('Enter number of days: ')) print('\nDay\t\tSalary') print('-----------------------') total_salary = 0.0 for d in range(1, days + 1): salary = (2 ** (d - 1)) / 100 total_salary += salary print(d, '\t\t', '$', format(salary, ',.2f'), sep='') print('\nTotal Pay: $', format(total_salary, ',.2f'), sep='') main() 10. Largest and Smallest: def main(): for r in range(6): print('#', end='') for c in range(r): print(' ', end='') print('#') main()...

View
Full Document

- Fall '14
- Control flow, loop, sentinel value, total_rainfall += rainfall