Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Code must be in Python 3. Purpose: To practice recursion with a simple example Degree of Difficulty: Easy Moosetopia's most famous rocket scientist, Zeno, has

Code must be in Python 3.

image text in transcribed

Purpose: To practice recursion with a simple example Degree of Difficulty: Easy Moosetopia's most famous rocket scientist, Zeno, has invented a new kind of space ship which will enable interstellar travel across the large distances of space very quickly. The technology is very complicated, and involves a lot of tedious messing about in hyperspace, but the actual motion of the ship is quite simple: If the distance to the destination is greater than 1 meter, the ship will "fold space" and jump" to a position half way to the destination. It takes exactly one minute for the ship's computer to do the calculations prior to the jump. The jump itself is instantaneous. . Any distance of 1 meter or less will take exactly one minute, using normal impulse rockets. For example, if the ship has to travel 10 meters, it will jump 5 meters after the first minute, 2.5 meters the second minute, 125 meters the 3rd minute, and 0.625 meters the fourth minute. Finally, the remaining 0.625 meters takes one more minute. Thus the total time to travel 10 meters is 5 minutes. (That seems very slow, and it is for small distances, the true value of this method only reveals itself for large distances.) Write a recursive function called spaceTime ) that calculates the time needed for Zeno's ship to travel a given distance. In the same file, write a program that asks the user for a distance in meters (console input) then call your spaceTime) function to calculate the time required to travel the given distance Test your function out on all of the following examples: Average distance between the Zeno, and the nearest coffee shop: 537 meters (about a typical Moose topia city block) . Average distance between the planet Moosetopia and its biggest moon: 3.84e8 meters (about 400 thousand km) . Average distance between our earth and our sun: 149el1 meters (about 150 million km) Approximate distance between the sun and the closest star: 4.0e16 meters (about 4 light-years) Size of the observable universe: 8.8e26 meters (about 93 Giga-light-years) Sample Run Here is an example execution of the required program. Zeno ' s drive requires: - 11 minutes to travel 537 meters to Zeno's nearest coffee shop - 30 minutes to travel 384000000.0 meters from Moosetopia to its biggest moon -39 minutes to travel 149000000000.0 meters from our earth to our sun -57 minutes to travel 4e+16 meters from our sun to the nearest star - 91 minutes to travel 8.8e +26 meters across the observable universe Your console output doesn't have to look exactly like the above. Copy/paste your output for all of the examples above into a document called a7q1_output.txt for submission. What to Hand In A document called a7q1.py containing your finished program, as described above A document called a7q1_output.txt (rtf and pdf formats are also allowable) with the output of your program copy/pasted into it, to demonstrate that your program works

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

Database Marketing The New Profit Frontier

Authors: Ed Burnett

1st Edition

0964535629, 978-0964535626

More Books

Students also viewed these Databases questions

Question

Provide several definitions of risk perception and risk tolerance.

Answered: 1 week ago

Question

The function range ( 4 ) returns a sequence

Answered: 1 week ago

Question

recognise typical interviewer errors and explain how to avoid them

Answered: 1 week ago

Question

identify and evaluate a range of recruitment and selection methods

Answered: 1 week ago

Question

understand the role of competencies and a competency framework

Answered: 1 week ago