Question

In: Computer Science

(PYTHON) A beard-second is a unit of length inspired by the light-year and is defined as...

(PYTHON) A beard-second is a unit of length inspired by the light-year and is defined as the length the average beard grows in one second, or precisely 5 nanometers. The beard-second is used for extremely short distances such as measurements within an integrated circuit. Your manufacturing equipment is very accurate but it uses inches as a unit of measurement, so you need a conversion table between beard-seconds and inches to complete a special order.

The following information should be helpful: 1 beard second = 5 nanometers 1 nanometer = 3.937e-8 inches

Write a program named beard.py that includes two functions main() and inches()which are used to produce a conversion table between beard seconds and inches for a series of values specified by the user.

The main() function: • Displays a description of the program’s function • Prompts the user for the starting and ending beard second value to be converted to inches • Displays a table header (see examples) • Using a loop, calls the inches() function repeatedly to calculate the converted values • The beard second values should increment by 250

The inches() function: • Accepts one (1) value in beard seconds as an argument • Performs the conversion calculation from beard seconds to inches • Displays the table row including the beard seconds and inches values (to 8 decimal places) • Beard second values should have a thousands comma separator • Does not return any values

Solutions

Expert Solution

Here is the completed code for this problem. Comments are included, go through it, learn how things work and let me know if you have any doubts or if you need anything to change. If you are satisfied with the solution, please rate the answer. Thanks

Note: Please maintain proper code spacing (indentation), just copy the code part and paste it in your compiler/IDE directly, no modifications required.

#CODE

#constants for measurements in different units
NANOMETER=3.937e-8 #nanometer to inches
BEARD_SECOND_TO_INCHES=NANOMETER*5 #beard second to nanometers to inches

#required method to convert beard seconds to inches

def inches(beard_sec):
    #converting beard_sec to inches
   
inc=beard_sec*BEARD_SECOND_TO_INCHES
    #creating a formatted string containing inc separated by comma for every
    #1000's places
   
sec='{:,}'.format(beard_sec)
    #displaying sec with a field width of 10 spaces and inc with a precision of 8
    #digits after the decimal point
   
print('{:10s} {:.8f}'.format(sec,inc))


#main method
def main():
    #displaying description
   
print('This program converts beard seconds to inches')
    #reading start and end values for beard seconds
   
start=int(input("Enter starting beard second value: "))
    end = int(input("Enter ending beard second value: "))
    #displaying heading
   
print('\n{:10s} {:.8s}'.format("Beard Sec", "Inches"))
    #looping as long as start <= end
   
while start<=end:
        #displaying beard seconds and inches for start
       
inches(start)
        #incrementing start by 250
       
start+=250


#calling main()
main()

#OUTPUT


Related Solutions

Python program to simulate breaking a unit-length pencil into two places. Repeat the experiment 100,000 times...
Python program to simulate breaking a unit-length pencil into two places. Repeat the experiment 100,000 times and determine the average size of the smallest, middle-size, and the largest pieces. Record the estimate of the average sizes in your program Please use comments to better explain what is happening in the code
A company manufactures light bulbs. These light bulbs have a length of life that is normally...
A company manufactures light bulbs. These light bulbs have a length of life that is normally distributed with a known standard deviation of 40 hours. If a sample of 36 light bulbs has an average life of 780 hours, find the 95 percent confidence interval for the population mean of all light bulbs manufactured by this company.
A converging lens with a focal length of 4.0cm is to the left of a second...
A converging lens with a focal length of 4.0cm is to the left of a second identical lens. When a feather is placed 11cm to the left of the first lens, the final image is the same size and orientation as the feather itself. What is the separation between the lenses? Express your answer using two significant figures.
PYTHON! Exercise 3 - Total Line length Write a python function that will return the total...
PYTHON! Exercise 3 - Total Line length Write a python function that will return the total length of line that passes through any number of provided points ( (x,y) ). The points should be passed as individual tuples or lists. The function should also have a parameter (True or False) to indicate whether the line should start from the origin, and that parameter should default to False. If True, the returned value should include the distance from the origin to...
A ray of light impinges on a mirror as shown in the figure. A second mirror...
A ray of light impinges on a mirror as shown in the figure. A second mirror is fastened at 90? to the first. Part A After striking both mirrors, at what angle relative to the incoming ray does the outgoing ray emerge? (Figure 1) ? = Part B What is the answer if the incoming angle is 30?? ? =
a) One international unit of an enzyme is defined as the amount that catalyzes: A. The...
a) One international unit of an enzyme is defined as the amount that catalyzes: A. The formation of one millimole of product in one minute. B. The formation of one micromole of product in one minute. C. The formation of one mole of product in one minute. D. The formation of one micromole of product in one hour. b) Which of the following expressions is used for determination of Km? A. Vo at 1/2 Vmax B. [S] at 1/2 Vmax...
A light year is the distance light travels in 1 year. Light travels at 3*108 meters*...
A light year is the distance light travels in 1 year. Light travels at 3*108 meters* sec-1. Write a program that calculates and displays the number of meters light travels in a year.
I am struggling to write a python script that calculates the average length ,max length shortest...
I am struggling to write a python script that calculates the average length ,max length shortest length and overall average length of of a snake and ladder game. I use python 3 The length is the number the dice is rolled until the max is reached We need a python script that calculates the number of moves it will take for a single player to reach 100. We have to simulate a snake and ladder game using python language. So...
For the year ending December 31, Beard Clinical Supplies Co. mistakenly omitted adjusting entries for (1)...
For the year ending December 31, Beard Clinical Supplies Co. mistakenly omitted adjusting entries for (1) $7,090 of unearned revenue that was earned, (2) earned revenue that was not billed of $8,970, and (3) accrued wages of $7,220. Indicate the combined effect of the errors on (a) revenues, (b) expenses, and (c) net income. Choose understated or overstated and fill in the blank. a. Revenues were (understated/overstated) by $______ b. Expenses were (understated/overstated) by $______ c. Net income was (understated/overstated)...
CO2 passes short wave length light (visible) but blocks long wave length radiation (IR).
CO2 passes short wave length light (visible) but blocks long wave length radiation (IR). Explain how adding CO2 to an atmosphere increases the surface temperature of a planet. Consider the temperature of the sources of radiation in and out.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT