Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This is a python question for recursion The evil Team Rocket has invented an incredible new space-ship! The ship works as follows: If the distance

This is a python question for recursion

The evil Team Rocket has invented an incredible new space-ship! The ship works as follows: If the distance to the destination is greater than 1 meter, the ship will "fold space" and "jump" to a position exactly half way to the destination. It takes exactly one minute to perform this process. 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, 1.25 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 Team Rockets new ship to travel a given distance (in meters). In the same file, write code that asks the user for a distance in meters (console input), and then calls your spaceTime() function to calculate the time required to travel the given distance. Test your function out on all of the following examples: Distance from Team Rockets base to the nearest Poke-Stop : 37 meters. Distance for a round-trip around the entire planet earth: 40075000 meters. Average distance between our earth and our sun: 1.49e11 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)

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

Transact SQL Cookbook Help For Database Programmers

Authors: Ales Spetic, Jonathan Gennick

1st Edition

1565927567, 978-1565927568

More Books

Students also viewed these Databases questions

Question

What is the principle of thermodynamics? Explain with examples

Answered: 1 week ago

Question

13. You always should try to make a good first impression.

Answered: 1 week ago