1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Ad libitum [116K]
3 years ago
10

Write the simulate method, which simulates the frog attempting to hop in a straight line to a goal from the frog's starting posi

tion of 0 within a maximum number of hops. The method returns true if the frog successfully reached the goal within the maximum number of hops; otherwise, the method returns false. TheFrogSimulationclass provides a method calledhopDistancethat returns an integer representing the distance (positive or negative) to be moved when the frog hops. A positive distance represents a move toward the goal. A negative distance represents a move away from the goal. The returned distance may vary from call to call. Each time the frog hops, its position is adjusted by the value returned by a call to thehopDistance method. g
Computers and Technology
1 answer:
Anvisha [2.4K]3 years ago
4 0

Answer:

Explanation:

The following code is written in Python. It creates the simulate method which takes in an argument for the max number of hops and the goal distance. Then it loops the number for the max number of hops and asks the user for a hop input using the hopDistance() method (which was not included so it was made, this can be removed if wanted). Then it updates position. If after the max hops goal was reached it returns True, otherwise it returns False.

def simulate(max, goal):

   position = 0

   print("Goal is " + str(goal))

   for x in range(max):

       hop = hopDistance()

       position += int(hop)

   if position >= goal:

       return True

   else:

       return False

def hopDistance():

   return input("Frog Hop Distance this hop: ")

print(simulate(4, 20))

You might be interested in
What has impacted the world more: The initial creation of telephone or a smart cellphone? Explain your reasoning!
-BARSIC- [3]
If this is on personal opinion, I would say the initial creation of the telephone. Even though a smartphone practically kickstarted a whole era to technology that is still going on till this day, it was the telephone that started this all. If it wasn’t for the idea to create a phone that is more advanced than a box attached to the wall, none of these advancements would’ve happened at all. (Although that is uncertain, things do tend to have a way of working out in the end. If someone didn’t invent it, another person would’ve thought of it sooner or later.) But that is only if we’re talking long term, which I prefer because there was no limit to when the results of impact started in the prompt stated above, yet if we were to speak short term and the faster one, the credit would go to the smart cellphone. But we aren’t, because the question never specified ;)
5 0
3 years ago
Is an applications program is a program designed to perform a specific task for specific users
Vika [28.1K]

Answer:

application software or tailored software

6 0
3 years ago
What kind of table is a pasted Word table that can be edited with Word from within PowerPoint without changing the data in your
igomit [66]

D. Integrated

Or

A. Embedded

7 0
3 years ago
Read 2 more answers
What are the features of page layout
bagirrra123 [75]

Typical page layout decisions include:

Size of page margins.

Size and position of images and figures.

Deciding on the number and size of columns and gutters (gaps between columns)

Placement of intentional whitespace.

4 0
3 years ago
Read 2 more answers
In which model does each computer in a network act as a server for all the other computers, sharing files and access to devices?
RoseWind [281]
The second one Client server?
6 0
3 years ago
Other questions:
  • Describe an ergonomic consideration for your body while working for long periods in front of a monitor or computer screen?
    14·1 answer
  • What is the wave speed of a wave that has a frequency of 100 Hz and a wavelength of 0.30m?
    5·1 answer
  • Which system utility can you use to troubleshoot a computer that's slow to start by enabling or disabling startup programs?
    7·2 answers
  • I need help plzzzzzzzz
    10·2 answers
  • Student creates a Raptor program and uses the File Input and Output method to find the average of 5 test scores stored in a text
    5·1 answer
  • Explain the strengths and weaknesses you have experienced with content information
    10·1 answer
  • Design a loop that asks the user to enter a number. The loop should iterate 10
    15·1 answer
  • A laptop can be kept on palm to work. [true/false) ​
    5·1 answer
  • GOOD EVENING, FRIENDS, I WANT TO ASK ON THE ACCOUNT OF HIS NAME‏BENJEMIN360 . THIS ANSWERS ARE VERY WONDERFUL, BUT I CAN'T COMMU
    6·1 answer
  • Why are my texts green when texting another iphone.
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!