Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need help with this problem. This problem is to done in python not java or c++ The assignment is exercise in using a particular

I need help with this problem. This problem is to done in python not java or c++

The assignment is exercise in using a particular language feature, loops. The intention is that you practice writing code with the small tasks. If you copy from other people you are only depriving yourself of an education. To learn, you have to think it through, yourself. Finding a solution online and copying it is easy, but leaves you facing the problem of learning what you were supposed to learn, in the context of a much harder problem the next time.

To practice writing loops, create a function called loops and inside the function write the four loops given below. Turn in this assignment with comments as a zip (or rar) folder as usual that contains only the source code.

1. Write a loop that counts from 10 down to 1, printing the count value each time in the loop. The output should look like (notice the spacing): 10 9 8 7 6 5 4 3 2 1 Call this loop within main().

2. Write a loop that counts from 5 to 100 by fives, printing the count in each iteration. The output should look like: 5,10,15,20,25,30,35,40,45,50,55,60,65,70,75,80,85,90,95,100 Notice the commas. Notice that there is no comma at the beginning or end. That means that you must do something special either at the beginning or at the end.

3. Ask the user to input an integer parameter The loop should count down, starting with the input number and ending with 0. For this you should use a while loop. The numbers should all appear on the same line.

So for example if the input number passed is 10 the output should be

10 9 8 7 6 5 4 3 2 1 0

4. Ask the user to input an integer parameter. The loop should count up, starting with the number 1 and up to the number that was passed as the input parameter. For this you should use a for loop. The numbers should all appear on the same line.

So for example if the number passed in using input is 7 the output should be

1 2 3 4 5 6 7

5. Name the file as YourLastNameLoops.py with the main function, do all these loops within the loops function. Do not submit 4 different programs.

Use end = to print out different variable counts in a single line inside a loop:

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

Practical Azure SQL Database For Modern Developers Building Applications In The Microsoft Cloud

Authors: Davide Mauri, Silvano Coriani, Anna Hoffma, Sanjay Mishra, Jovan Popovic

1st Edition

1484263693, 978-1484263693

More Books

Students also viewed these Databases questions

Question

4.12. Repeat Example 4.3 with and .

Answered: 1 week ago