Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hi i wish to seek advice on how to create a loop to loop back to the starting point but i am unsure of how

Hi i wish to seek advice on how to create a loop to loop back to the starting point but i am unsure of how to do it, please advise me accordingly if possible. The code is shown below:

#Starting Line

print("Welcome to the Musemum!!")

print("To begin, please indicate which type of scientist you are:")

Patron = float(input("0 = Rookie Scientist, 1 = Seasoned Scientist, 2 = Grizzled Scientist, any other entries will be treated as Rookie Scientist!:"))

if Patron == 1:

print("You have just entered Seasoned Scientist, the theme for the musemum today is the feature an echolocation model")

elif Patron == 2:

print("You have just entered Grizzled Scientist.")

print("Today the theme of our musemum is biomimicry - a scientific approach that incorporates nature's time tested patterns in human engineering to solve human challenges.")

print("More specifically, our exhibition today will feature echolocation of animals, a technology that is used in active sonar.")

print("Echolocation will be measured through a model that contains virables such as latitude, salinity, depth and temperature of water and the speed of sound in seawater.")

print("We hope that you will enjoy this visit.")

This is the starting point in which i would want my loop to come back to

print("To begin, please enter 1 for the variable 'go_again', enter any other values to quit")

go_again = float(input("Value of go_again:"))

if go_again == 1:

latitude = float(input("Please enter a latitude between 0 and 90, enter any other number to quit:"))

if latitude < 0:

print("You have choosen to quit, have a pleasant time here in the musemum!")

elif latitude > 90:

print("You have choosen to quit, have a pleasant stay here in the musemum!")

else:

salinity = (-1/4050) * latitude**2 + 36

print ("Do you want your latitude to be given in the North or South Hemisphere? Enter any other number to quit:")

hemisphere = float(input("Please enter 1 for North or 2 for South:"))

if hemisphere == 1:

print("The latitude that you have entered is:",latitude,"","N")

print ("The salinity of seawater at the latitude is:", salinity,"parts per thousand")

elif hemisphere ==2:

print("The latitude that you have entered is:",latitude,"","S")

print ("The salinity of seawater at the latitude is:", salinity,"parts per thousand")

else:

print("You have choosen to quit, have a plesant stay here in the musemum!")

print("Salinity of seawater is the measured by the amount of salt dissolved in per kilogram of seawater.")

print("The salinity of sewater is usually between the values of 34 to 36 parts per thousand. ")

print("It is a quadratic function of latitude.")

print("Assuming at the earth's equator where the latitude is 90,")

print("the relationship between the temperature of seawater vs the depth of seawater is as plotted below:")

D = array([0, 200, 400, 600, 800, 1000, 1200])

T = array([24, 24, 18.5, 13, 7.5, 2, 2])

plot(D, T, linewidth=3)

grid(True)

title("Temperature vs Depth")

xlabel("Depth of seawater")

ylabel("Temperature of seawater")

show()

print("The oceans are split into three zones which shows how temperature varies when depth increases.")

print("The three zones are: Surface Zone which carries water at depths between 0 to 200 meteres,")

print("The Thermocline Zone which compromises of water at depths 200 to 1000 metres and lastly,")

print("the deep zone which contains water exceeding the depth of 1000 metres.")

print("From the graph above, the line from the depth of 0 to 200 metres indicates the first zone, the Surface Zone,")

print("the decreasing linear trend indicates the thermocoline zone from a depth of 200 to 1000 metres, and the last line")

print("indicates the deep zone from 1000 metres onwards.")

print("The decreasing linear trend in the graph shows that as the depth of seawater increases, the temperature of the")

print("seawater decreases.")

print("For example, based on the graph, at a depth of 200 metres, the temperature of the seawater is at 24C, however")

print("at a depth of 600 metres, the temperature of the seawater decreased to only 13C.")

depth = float(input("Now, please enter a depth value that you desire:"))

if 0 <= depth <=200:

temp_of_seawater = (-22/90)*latitude+24

mackenzie_sos = 1448.96 + 4.591 * temp_of_seawater - 5.304 * (10**-2 * temp_of_seawater**2) + 2.374 * (10**-4 * temp_of_seawater**3) + 1.340 * (salinity - 35) + 1.630 * (10**-2) * depth + 1.675 * (10**-7 * depth**2) - 1.025 * (10**-2 * temp_of_seawater) * (salinity - 35) - 7.139 * (10**-13) * temp_of_seawater * depth**3

print("The temperature of the seawater at the given latitude and depth is:",temp_of_seawater,"(C)")

print("As shown in the previous graph, the temperatures were lower in the thermocline zone and the deep zone as")

print("compared to the surface zone. Hence, it is reasonable to consider both latitude and depth when calculating")

print("the temperature of seawater.")

print("Hence, for the given latitude, salinity and depth, we can calculate the speed of sound in seawater:", mackenzie_sos, "metres per second." )

print("The speed of sound as shown above is calculated by the Mackenzie equation, it compromises of mainly 3 variables,")

print("temperature, salinity and depth. The values that you have entered above are then subtituted into this equation to")

print("given us the speed in seawater.")

ret = float(input("Please enter a return time:"))

distance = ret/2 * mackenzie_sos

print("The distance to the object is:", distance, "metres.")

print("The return time you just entered is the time taken for the release of a sound to echo back to the same location")

print("Knowing the value of the return time, every values that is required to work out echolocation is completed.")

print("Great Job! Thank you for your patronage to this museum.")

float(input("Please........."))

elif depth < 0:

print("You have entered an incorrect value of depth, please try again from the start.")

elif 201 <= depth <= 1000:

temp_of_seawater = (22/90 * latitude -22)/800 * (depth - 200) + (-22/90 * latitude + 24)

mackenzie_sos = 1448.96 + 4.591 * temp_of_seawater - 5.304 * (10**-2 * temp_of_seawater**2) + 2.374 * (10**-4 * temp_of_seawater**3) + 1.340 * (salinity - 35) + 1.630 * (10**-2) * depth + 1.675 * (10**-7 * depth**2) - 1.025 * (10**-2 * temp_of_seawater) * (salinity - 35) - 7.139 * (10**-13) * temp_of_seawater * depth**3

print("The temperature of the seawater at the given latitude and depth is:",temp_of_seawater,"(C)")

print("As shown in the previous graph, the temperatures were lower in the thermocline zone and the deep zone as")

print("compared to the surface zone. Hence, it is reasonable to consider both latitude and depth when calculating")

print("the temperature of seawater.")

print("Hence, for the given latitude, salinity and depth, we can calculate the speed of sound in seawater:", mackenzie_sos, "metres per second." )

print("The speed of sound as shown above is calculated by the Mackenzie equation, it compromises of mainly 3 variables,")

print("temperature, salinity and depth. The values that you have entered above are then subtituted into this equation to")

print("given us the speed in seawater.")

ret = float(input("Please enter a return time:"))

distance = ret/2 * mackenzie_sos

print("The distance to the object is:", distance, "metres.")

print("The return time you just entered is the time taken for the release of a sound to echo back to the same location")

print("Knowing the value of the return time, every values that is required to work out echolocation is completed.")

print("Great Job! Thank you for your patronage to this museum.")

float(input("Please........."))

I would like the user to input a value of 1 for the variable go_again to loop back to the starting point and all other values to end the coding here.

else:

temp_of_seawater = 2

mackenzie_sos = 1448.96 + 4.591 * temp_of_seawater - 5.304 * (10**-2 * temp_of_seawater**2) + 2.374 * (10**-4 * temp_of_seawater**3) + 1.340 * (salinity - 35) + 1.630 * (10**-2) * depth + 1.675 * (10**-7 * depth**2) - 1.025 * (10**-2 * temp_of_seawater) * (salinity - 35) - 7.139 * (10**-13) * temp_of_seawater * depth**3

print("The temperature of the seawater at the given latitude and depth is:",temp_of_seawater,"(C)")

print("As shown in the previous graph, the temperatures were lower in the thermocline zone and the deep zone as")

print("compared to the surface zone. Hence, it is reasonable to consider both latitude and depth when calculating")

print("the temperature of seawater.")

print("Hence, for the given latitude, salinity and depth, we can calculate the speed of sound in seawater:", mackenzie_sos, "metres per second." )

print("The speed of sound as shown above is calculated by the Mackenzie equation, it compromises of mainly 3 variables,")

print("temperature, salinity and depth. The values that you have entered above are then subtituted into this equation to")

print("given us the speed in seawater.")

ret = float(input("Please enter a return time:"))

distance = ret/2 * mackenzie_sos

print("The distance to the object is:", distance, "metres.")

print("The return time you just entered is the time taken for the release of a sound to echo back to the same location")

print("Knowing the value of the return time, every values that is required to work out echolocation is completed.")

print("Great Job! Thank you for your patronage to this museum.")

float(input("Please........."))

else:

print("You have choosen to quit, have a plesant stay here in the musemum!")

else:

print("You have just entered Rookie Scientist, today the musemum is showing off the super cool abilities animals in the ocean have!")

print("One of these abilities is called echolocation!")

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Dental Assisting

Authors: Doni Bird, Debbie Robinson

13th Edition

978-0323624855, 0323624855

Students also viewed these Programming questions