# CS 190C, Lab 1: January 16, 2009

• Course survey
• Accessing your ITaP home drive from another computer:
• For CS home drive, replace rosetta.ics.purdue.edu with vermouth.cs.purdue.edu

## Discussed Programs

```principal = input("Principal: ")
rate = input("Annual percentage rate: ")
for year in range(10):
principal = principal * (1+rate)
print principal```
```n = input("How many numbers? ")
avg = 0
for i in range(n):
x = float(input("Enter next number: "))
avg = avg + x/float(n)
print avg```

## In-Lab Problems

Convert and print a range of temperatures from degrees Fahrenheit to degrees Celsius. The formula to do so is tempC = (5/9)*(tempF - 32). Do this for the following ranges (inclusive for both min/max):

1. Every degree from -20 through 32
2. Every ninth degree from 5 through 212
3. Every other degree from 80 to 30 (it must print the higher values first)

You should print the degrees in Fahrenheit and degrees Celsius for each requested value.

## Solution

```print 'Degrees F\tDegrees C'
for degF in range(-20, 33):
degC = (degF - 32) / 1.8
print degF, '\t\t', degC
for degF in range(5, 213, 9):
degC = (degF - 32) / 1.8
print degF, '\t\t', degC
for degF in range(80, 30, -2):
degC = (degF - 32) / 1.8
print degF, '\t\t', degC```