Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please help me with these problems using Python. 1. Develop a program that reads a four-digit integer from the user and displays the sum of
Please help me with these problems using Python.
1. Develop a program that reads a four-digit integer from the user and displays the sum of its digits. For example, if the user enters 3141 then your program should display 3+1+4 +1 = 9. 2. The following table lists an octave of music notes, beginning with middle C, along with their frequencies. Note C4 D4 E4 F4 G4 A4 B4 Frequency (Hz) 261.63 293.66 329.63 349.23 392.00 440.00 493.88 Begin by writing a program that reads the name of a note from the user and displays the note's frequency. Your program should support all of the notes listed previously. Once you have your program working correctly for the notes listed previously you should add support for all of the notes from Co to C8. While this could be done by adding many additional cases to your if statement, such a solution is cumbersome, inelegant and unacceptable for the purposes of this exercise. Instead, you should exploit the relationship between notes in adjacent octaves. In particular, the frequency of any note in octave n is half the frequency of the corresponding note in octave n + 1. By using this relationship, you should be able to add support for the additional notes without adding additional cases to your if statement. Hint: You will want to access the characters in the note entered by the user individually when completing this exercise. Begin by separating the letter from the octave. Then compute the frequency for that letter in the fourth octave using the data in the table above. Once you have this frequency you should divide it by 24-x where x is the octave number entered by the user. This will halve or double the frequency the correct number of times. 3. Write a program to calculate the perimeter p of an n-gon inscribed inside a sphere of diameter 1. Find p for n = 3,4,5, 100, 10,000, and 1,000,000. Your answers should be 11 11 3 2.59807621135 100 3.141 07590781 4 2.82842712475 10,000 3.14159260191 5 2.93892626146 1,000,000 3.14159265358Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started