Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This needs to be a python function You are a scientist at NASA and you have been contacted by Planet X in another solar system.

This needs to be a python function

image text in transcribed

You are a scientist at NASA and you have been contacted by Planet X in another solar system. The messages sent by Planet X are encoded in the form of a mathematical series called a "hopscotch sequence. You have successfully decoded this hopscotch sequence and now you wish to send a message back to planet X. The nth term of the sequence is given by: An = ( 2 4n-3) + 4n-z + (4. An-1) For example, if the first three values in the sequence were 1, 2 and 3. The fourth value would be: 12 - 1) - 2 + (4 - 3) = 16 Replacing the previous three Integers (2, 3 and 16) in the formula would determine the fifth value in the sequence. The nth term can be calculated by repeating this process. Write a program named hopscotch.py that includes two functions main() and hop() which are used to determine the nth term in the hopscotch sequence. The main() function: Displays a description of the program's function Prompts the user for the number of values in the sequence (n) Prompts the user for the first three values in the sequence Using a loop, calls the hop() function repeatedly until the nth value is determined Displays the nth value of the hopscotch sequence The hop() function: . Accepts three values as arguments Calculates the next value in the hopscotch sequence Returns the calculated value Your program must include an appropriate header, be fully documented using comments, and produce the correct values and output matching the examples below. This program determines the nth value of a Hopscotch sequence This program determines the nth value of a Hopscotch sequence Enter the total number of values (n): 5 Enter the total number of values (n): 8 Enter the 1st value: 12 Enter the 2nd value: Z Enter the 3rd value: 41 Enter the 1st value: -3 Enter the 2nd value: 5 Enter the 3rd value: -6 Value 5 in this hopscotch sequence is: 885 Value 8 in this hopscotch sequence is: -7,933 This program determines the nth value of a Hopscotch sequence This program determines the nth value of a Hopscotch sequence Enter the total number of values (n): 12 Enter the total number of values (n): 6

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

More Books

Students also viewed these Databases questions

Question

Explain all drawbacks of application procedure.

Answered: 1 week ago

Question

Explain the testing process of accounting 2?

Answered: 1 week ago

Question

Ensure continued excellence in people management.

Answered: 1 week ago

Question

Enhance the international team by recruiting the best people.

Answered: 1 week ago