Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

CSC 1 2 1 LAB 0 3 : REPETITION STRUCTURES GOALS In this lab assignment, students will demonstrate the ability to: Use loops to solve

CSC121 LAB 03:
REPETITION STRUCTURES
GOALS
In this lab assignment, students will demonstrate the ability to:
Use loops to solve problems
Create and use condition-controlled loops
Create and use count-controlled loops
Calculate a running total
Create and use input validation loops
Create and use nested loops
NOTE: This lab document is a copyrighted work of Wake Tech Community College and the course instructor. Any posting of this document outside of Wake Tech is considered a copyright violation. Students who post these documents outside of Wake Tech are subject to academic and possible legal actions.
INSTRUCTIONS
In this lab, you will demonstrate your mastery of repetition structures.
Follow the instructions in each problem and submit the specified files. All problems will require that Python code be submitted as well as screenshots that prove the programs have been executed in PyCharm.
Problems 1 and 2 will start with code provided by the instructor that either needs to be fixed or completed. Problem 3 will consist of a program that you create from scratch that meets the problem specification.
PROBLEMS
PROBLEM 1
In this problem, you are given a completed program that has errors. You need to fix the errors.
This flawed program is supposed to estimate the inventory of books, DVDs, and games in Trish's Bargain Swap Shop.
Initially the program asks for the current number of books, DVDs, and games.
The program then assumes that there will be a net gain of 45 books per month, 32 DVDs per month and 15 games per month, and it shows the amounts of each item in stock each month for the next 3 months.
The instructor has provided a file called Lab03P1-FixTheErrors.py.
Download that file and rename it Lab03P1.py.
Copy that file into your PyCharm project.
Change the program header to include your name and the date.
Run the program AS IS and see if you can determine what is wrong with the program. Note: You do NOT need a screen shot of the error for this problem.
Correct all the errors. You should eventually be able to run the program with no errors that accurately produces a table like the sample output.
Sample Output:
What is the current number of books? 20
What is the current number of DVDs?100
What is the current number of games? 35
Month 1
Books: 65
DVDs: 132
Games: 50
Month 2
Books: 110
DVDs: 164
Games: 65
Month 3
Books: 155
DVDs: 196
Games: 80
Run this program using the PyCharm Terminal. Take a screenshot of the Terminal that includes the line showing where you started the program run with the results. Name the screenshot Lab03P1-ouput.jpg.
Submit both files, Lab03P1.py and Lab03P1-output.jpg, to Blackboard for credit.
PROBLEM 2
In this problem, you are given a partially completed program, and you need to update and fill in the rest of the program to produce the desired output.
This program should ask the user to enter a number of rows and a number of columns. The program will then print a pattern based on the user's input. The pattern follows these rules:
If the row is even numbered (2nd,4th, etc.) and the column is even numbered, then the character in that spot will be a blank or space character.
Otherwise, the character in that spot will be an asterisk: "*"
Sample output 1:
How many rows? 7
How many columns? 7
*******
****
*******
****
*******
****
*******
Sample output 2:
How many rows? 6
How many columns? 12
************
******
************
******
************
******
HINT: Be careful about how the numbers work in your program. Often times a program may be counting numbers starting with 0 when a user may be counting from 1.
HINT: When determining if a number is even or odd, the modulus or remainder operator can be very helpful.
The instructor has provided a file called Lab03P2-FillThisIn.py. Download that file and rename it Lab03P2.py.
Copy that file into your PyCharm project.
Change the program header to include your name and the date.
ONLY replace every instance of "--Fill this in--" with correct code that will enable the program to generate the patterns shown above.
Run this program using the PyCharm Terminal.
Take a screenshot of the Terminal that includes the line showing where you started the program run with the results.
Name the screenshot Lab03P2-ouput.jpg.
Submit both files, Lab03P2.py and Lab03P2-output.jpg, to Blackboard for credit.
PROBLEM 3
Trish at Bargain Swap Shop has been using the programs you developed for her and really likes them. Recently however, she hired a new cashier who isn't very good at data entry. In particular, she needs the program to catch data entry errors that are made and give the user a chance to reenter the data.
To help her out, you'll be taking the first program you developed for her (Lab 01 Problem 4)

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 And Transaction Processing

Authors: Philip M. Lewis, Arthur Bernstein, Michael Kifer

1st Edition

0201708728, 978-0201708721

More Books

Students also viewed these Databases questions

Question

=+such as the dirigenti in Italy?

Answered: 1 week ago

Question

=+ Are there closed-shop requirements or practices?

Answered: 1 week ago