Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Focus 1. While loops and For loops 2. Count-controlled loops 3. Sentinel controlled loops This lab maps to learning objectives 1 through 7 Competency Four

Focus 1. While loops and For loops 2. Count-controlled loops 3. Sentinel controlled loops This lab maps to learning objectives 1 through 7 Competency Four - Write a Working Program that Uses the Repetition Control Structure including the While Loop, the For Loop, and Nested Loops Part A: Building upon an Existing Solution For this portion of the lab, you will reuse the program you wrote in Lab 3A. That means you will open the lab you wrote in the previous assignment and change it. You should NOT start from scratch. Also, all the requirements/prohibitions from the previous lab MUST also be included /omitted from this lab. (That means DO NOT functions, list, a menu etc) In addition break, quit, exit, sys.exit, return, continue, or any other shortcut ion NEVER allowed. Redesign the solution so that some portions of the code are repeated. In lab 4 you validated input to ensure that the user entered inputs within certain values. If the user entered an invalid value, the program terminated. Now you will add a loop such that the user gets three chances to enter a valid value. If the user enters an invalid value more than three times in a row, the program should issue an error message and terminate (LO 1.1, 1.2, 2, 3, 5, 6). LO refers to the Learning Objectives from the PowerPoints and are tied to the books learning objectives. 1. Save the program as firstname_lastname_Lab4a.py where you will replace firstname and lastname with your actual first and last name. 2. Test all conditions prior to submitting. Part B: Draw Something! DO NOT functions, list, a menu etc) In addition break, quit, exit, sys.exit, return, continue, or any other shortcut ion NEVER allowed. In this portion of the lab you will draw an inverted triangle using loops (LO 1.1, 1.2, 3, 5, 6) ********** ********* ******** ******* ****** ***** **** *** ** * Save the program as firstname_lastname_Lab4b.py where you will replace firstname and lastname with your actual first and last name. Part C: Write Something New! Write a complete and syntactically correct Python program to solve the following problem: You are the professor for COSC 1336 at Austin Community College. You want to write a program that will take in the numeric grades of the students in your class. Since the students in a class vary from semester to semester, there is no fixed number assigned to the number of students. You will keep track of how many students grades you input. You will stop taking input when the student enters a grade of -1. (LO 1.1, 1.2, 4, 5, 6)\ Learning Objectives Upon completion of this competency, the students should be able to: Design a simple program using while loop for loop Comprehend and explain condition-control loops Comprehend and explain count-controlled loops Comprehend and explain sentinels Write a syntactically correct program using a while loop Write a syntactically correct program using a for loop DO NOT functions, list, a menu etc) In addition break, quit, exit, sys.exit, return, continue, or any other shortcut ion NEVER allowed. Your program will use loops and will accomplish the following: 1. Read in a numeric grade from a student. 2. Convert the numeric grade to a letter grade using the grade policies in your syllabus. 3. Keep a running total of the numeric grades entered. 4. Keep a count of the number of grades entered. 5. Issue a message that comments on the letter grade earned. As an example, you may write You made an F! Obviously you did not study! 6. At the end the program will calculate a class average unless there were no grades entered. All input to the program will be interactive from the keyboard. The output of the program will include the individual grades converted, the message issued to the student, a class average, and the number of grades entered. Use the IDLE programming environment if you are using Python with IDLE. Some of you may be using Komodo or some other Python IDE. Please save your file as firstname_lastname_Lab4c.py where you will replace firstname and lastname with your actual first name and last name. Remember to use the extension .py. Run and test your program for all conditions. Once you are sure it works you will turn in the items listed in the next section. Turn In All labs will be graded in Blackboard. Once you are done with the lab turn it in to the Lab this is the lab for 3A. This is the code that cannot be changed # Lab Exercise 3 - Part A # Author: Corinna Clark # Date: 2/24/2023 #Prompt the user to enter the miles. Miles = float(input('Enter the miles to convert into kilometer: ')) #Check the miles. if Miles >= 0 : #Convert the miles to kilometers. Miles_To_km = Miles*1.6 #Display the result. print (Miles, "miles equivalent to", Miles_To_km, "kilometer.") #Prompt the user to enter the gallons. Gallon = float(input('Enter the gallons to convert into liter: ')) #Check the validity of the Gallons entered. if Gallon >= 0: #Convert gallons into liters. Gal_To_Lit = Gallon*3.9 #Display the result. print (Gallon, "gallons equivalent to", Gal_To_Lit, "liters.") #Prompt the user to enter the pounds. Pound = float(input('Enter the pounds to convert into kilograms: ')) #Check the validity of the Pounds entered. if Pound >= 0: #Convert pounds into kilograms. Pounds_To_Kg = Pound*0.45 #Display the result. print (Pound, "pounds equivalent to", Pounds_To_Kg, "kilograms.") #Prompt the user to enter the temperature in Fahrenheit. f = float(input('Enter the temperature in Fahrenheit: ')) #Check the value to be not greater than 1000. if f < 1000: #Convert Fahrenheit into celsius. F_To_C = (f -32)*5/9 #Display the result. print (f, "Fahrenheit equivalent to", F_To_C, "celsius.") #Otherwise. else: #Display the error message. print ("Invalid temperature (greater than 1000) !!!") else: #Display the error message. print ("Pounds cannot be negative !!!") else: #Display the error message. print ("Gallons cannot be negative !!!") else: #Display the error message. print ("Miles cannot be negative !!!")

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

PC Magazine Guide To Client Server Databases

Authors: Joe Salemi

1st Edition

156276070X, 978-1562760700

More Books

Students also viewed these Databases questions

Question

Define the term Working Capital Gap.

Answered: 1 week ago