Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

CSCI-130 Assignment #4: Practicing Loops Description: Write a Python program (script) named LoopPractice.py This assignment consists of a single program that you will write from

image text in transcribed
image text in transcribed
image text in transcribed
CSCI-130 Assignment \#4: Practicing Loops Description: Write a Python program (script) named LoopPractice.py This assignment consists of a single program that you will write from scratch. However, it does not follow the IPO (Input-ProcessOutput) design we have used in assignments 2 and 3 . This program will look more like what we wrote when seeing different ways of writing a loop. It has four sections, and each section should start with comments describing what it does. Details below: - Start your program with 2 output lines (see example on next page) with your name and a line of hyphens. In the examples seen at the end of this document, replace "FIRST LAST" with your names (no need to capitalize the, I wrote them that way so they would stand out from the rest of the text). A. Section A will use a loop to print a type of bird (robin, blue jay, swan... your choice) inside a phrase, exactly 3 times (in the sample output at the end of this document, you will see in place of the type of bird-replace this with your chosen bird name). B. Before the loop, print the 3 heading lines seen in sample output. In section B, make a list of 6 (random - you choose the values) numbers, and use the loop to print each number, followed by the phrase plus 2 equals, followed by the number from that list after you add 2 to it. For an example of using a loop with a list, see page 44 of your textbook. (In my example output, my list contained the numbers 9,6,4,5,7 and 0 .) C. In section C : a. Ask for an integer count value from the keyboard to tell this loop how many times to run. Each time it runs, you will print a number as well as the name of a favorite color. b. Before the loop, print the 3 heading lines seen in sample output. Notice that within the middle heading line, you should print the number entered in part C.a. explained above. c. Within the loop body, print the text plus the line number inside parentheses. Use sep = at the end of your print (O statement so that you don't see extra space characters where you don't want them, such as inside each side of the parentheses. The loop in section D will run one less time than the lumber entered for section C. So, for example, if you ntered a 5 to indicate how many times the section C loop uns, section D's loop will run 4 times. Inside your loop, the ode will keep adding the squares of numbers from the cyboard and print a final total after the loop finishes. a. Before the loop begins, create a variable to hold the number of times it will run (take the number from section C and subtract 1 from it). b. Also, before the loop begins, print the "Section D" heading line, plus 3 more lines of text (see example output). c. Create a variable to hold the final total (initialize it to zero). d. Within the loop body: i. ask the user for a number (match text seen in example on next page), ii. multiply the number times itself to get its square, iii. print the value you just calculated, iv. add that (squared) number to the variable you initialized to zero. e. After the loop finishes, print the total number

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

Database Design Application Development And Administration

Authors: Michael V. Mannino

4th Edition

0615231047, 978-0615231044

More Books

Students also viewed these Databases questions

Question

=+2 Why are so many countries bothered by their brain drains?

Answered: 1 week ago