1. Write a python code to solve Exercise 35 from “The Python Workbook.”
2. Write a python code to solve Exercise 39 from “The Python Workbook.”
I have attached the questions.
1. Write a python code to solve Exercise 35 from “The Python Workbook.”
2. Write a python code to solve Exercise 39 from “The Python Workbook.”
Exercise 35: Dog Years
(22 Lines)
It is commonly said that one human year is equivalent to 7 dog years. However this simple
conversion fails to recognize that dogs reach adulthood in approximately two years. As a result,
some people believe that it is better to count each of the first two human years as 10.5 dog
years, and then count each additional human year as 4 dog years.
Write a program that implements the conversion from human years to dog years described in
the previous paragraph. Ensure that your program works correctly for conversions of less than
two human years and for conversions of two or more human years. Your program should
display an appropriate error message if the user enters a negative number.
Exercise 39: Sound Levels
(30 Lines)
The following table lists the sound level in decibels for several common noises.
Noise
Decibel level (dB)
Jackhammer
130
Gas lawnmower
106
Alarm clock
70
Quiet room
40
Write a program that reads a sound level in decibels from the user. If the user enters a decibel
level that matches one of the noises in the table then your program should display a message
containing only that noise. If the user enters a number of decibels between the noises listed
then your program should display a message indicating which noises the level is between.
Ensure that your program also generates reasonable output for a value smaller than the
quietest noise in the table, and for a value larger than the loudest noise in the table.