15-110 PA2 Sample Solutions - Spring 2018 1. def compute_rate(P,Q,n): return (Q/P)**(1/n) - 1 2. import math def tetra_volume(edge_length): return (edge_length**3)/(6 * math.sqrt(2.0)) def print_volume(): tetra1 = tetra_volume(15) tetra2 = tetra_volume(10) tetra3 = tetra_volume(20) # 2 cm = 20 mm total = tetra1 + tetra2 + tetra3 print("The total volume in cubic millimeters is ", end="") print(total) return None 3. def compute_freq(freq_in_Hz, cents): new_freq = freq_in_Hz * 2**(cents/1200) return new_freq def major_chord(root_freq): print(compute_freq(root_freq, 0)) # or just print(root_freq) print(compute_freq(root_freq, 400)) print(compute_freq(root_freq, 700)) return None 4. def add_minutes(minute, m): return (minute + m) % 60 def add_hours(hour, h): return (hour - 1 + h) % 12 + 1