Question

Assume the earth’s continents drift about 1.25 centimeters per year. Write a Python program/script using a...

Assume the earth’s continents drift about 1.25 centimeters per year. Write a Python program/script using a for-loop to display the total number of centimeters that the continents will have moved each year for the next 50 years.

a. What tasks need to be repeated (write in words)?
b. What is the start point of the loop and why?
c. What is the end point of the loop and why?
d. What is the start value for the initial drift and why?
e. Write the algorithm to output the following and provide the code in this file.
Output should look just like the following (will lose points for not following this format):
In year 1 the continents will have moved a total of 1.25 cm.
In year 2 the continents will have moved a total of 2.5 cm.

Homework Answers

Answer #1

a.) The drift variable to track the total drift which is increased by 1.25 in each iteration.

The drift variable tracking the total drif should be printed in each iteration of the loop.

b.) The start point of the loop is 1 as we need to calculate total drift from now till 50 years.

c.) The end point of the loop is upto 51 , to perform 50 iterations so as to calculate total drift for the next 50 years.

d.) The start value for the initial drift is 0 as we need to calculate total drift from now till 50 years.


drift = 0
for i in range(1,51):
    drift = drift + 1.25
    print("In year",i,"the continents will have moved a total of",drift,"cm.")
    

OUTPUT:

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Using C++, Python, or Java, write a program that: In this programming exercise you will perform...
Using C++, Python, or Java, write a program that: In this programming exercise you will perform an empirical analysis of the QuickSort algorithm to study the actual average case behavior and compare it to the mathematically predicted behavior. That is, you will write a program that counts the number of comparisons performed by QuickSort on an array of a given size. You will run the program on a large number of arrays of a certain size and determine the average...
In each of the projects that follow, you should write a program that contains an introductory...
In each of the projects that follow, you should write a program that contains an introductory docstring. This documentation should describe what the program will do (analysis) and how it will do it (design the program in the form of a pseudocode algorithm). Include suitable prompts for all inputs, and label all outputs appropri- ately. After you have coded a program, be sure to test it with a reasonable set of legitimate inputs. 1 The tax calculator program of the...
Write a Python 3 program called “parse.py” using the template for a Python program that we...
Write a Python 3 program called “parse.py” using the template for a Python program that we covered in this module. Note: Use this mod7.txt input file. Name your output file “output.txt”. Build your program using a main function and at least one other function. Give your input and output file names as command line arguments. Your program will read the input file, and will output the following information to the output file as well as printing it to the screen:...
You will write a program that loops until the user selects 0 to exit. In the...
You will write a program that loops until the user selects 0 to exit. In the loop the user interactively selects a menu choice to compress or decompress a file. There are three menu options: Option 0: allows the user to exit the program. Option 1: allows the user to compress the specified input file and store the result in an output file. Option 2: allows the user to decompress the specified input file and store the result in an...
Sign In INNOVATION Deep Change: How Operational Innovation Can Transform Your Company by Michael Hammer From...
Sign In INNOVATION Deep Change: How Operational Innovation Can Transform Your Company by Michael Hammer From the April 2004 Issue Save Share 8.95 In 1991, Progressive Insurance, an automobile insurer based in Mayfield Village, Ohio, had approximately $1.3 billion in sales. By 2002, that figure had grown to $9.5 billion. What fashionable strategies did Progressive employ to achieve sevenfold growth in just over a decade? Was it positioned in a high-growth industry? Hardly. Auto insurance is a mature, 100-year-old industry...