Accounting | Business | Computer
Science | General
Studies | Math | Sciences | Civics Exam | Help/Support | Join/Cancel | Contact Us | Login/Log Out
Exam 1 2 3 4 5 6 7 8 9 10 Midterm 1 2 Final Exam 1 2 Graded Program Assignment 1 2 3 4 5 6 7 8 9 Python Compiler Computer Programming Assignment 5 Age Classifier For-Loop Age_Classifier_FOR_LOOP # PROGRAM NAME: Age Classifier "For Loop" # DATE WRITTEN: June 10, 2019 # PURPOSE: Demonstate "While Loop" to "For Loop" Conversion # ========================================================================================== # Declare / Initialize Variables # Define the target or ending value print("How many people's ages would you like to process today? <enter a positive whole number> "); howMany = int(input()); # ========================================================================================== # For Loop for count in range(1, howMany + 1, 1): # INPUT STATEMENTS print("=" * 90) print("Enter your name "); name = input() print(name + " please enter a person's age: "); howOld = int(input()) # ========================================================================================== # Decision statement to determine age classification # Decision statement to determine age classification # IF STATEMENTS if howOld <= 1: classification = " an infant." else: if howOld > 1 and howOld < 13: classification = " a child." else: if howOld >= 13 and howOld < 20: classification = " a teenager." else: if howOld >= 20: classification = " an adult." # ========================================================================================== # OUTPUT STATEMENTS print(name + " this individual is classified as " + classification); print("=" * 90); # ========================================================================================== # CLOSING STATEMENTS print("=" * 90) print("Thank you for the age classification information."); print("=" * 90); # ========================================================================================== # END PROGRAM # PROGRAM NAME: Age Classifier While Loop # DATE WRITTEN: June 10, 2019 # PURPOSE: Demonstrate basic "While Loop" concept with Python # ===================================================================================================== # Declare variable names and data types # ===================================================================================================== # define the lcv answer print("Do you wish to classify a person's age? <type 'Y' or 'y'> [otherwise type 'no'] "); answer = input(); # ===================================================================================================== # While loop to do more than one age classification while answer == "y" or answer == "Y": # INPUT STATEMENTS print("=" * 90); print("Enter your name "); name = input() print(name + " please enter a person's age: "); age = int(input()) # Decision statement to determine age classification # IF STATEMENTS if age <= 1: classification = " an infant." else: if age > 1 and age < 13: classification = " a child." else: if age >= 13 and age < 20: classification = " a teenager." else: if age >= 20: classification = " an adult." # OUTPUT STATEMENTS print(name + " this individual is classified as " + classification); print("=" * 90); print("Do you wish to classify a person's age? <type 'Y' or 'y'> [otherwise type 'no'] "); answer = input(); # ===================================================================================================== # CLOSING STATEMENTS print("=" * 90); print("=" * 90) print("Thank you for the age classification information."); print("=" * 90); # ===================================================================================================== # END PROGRAM # PROGRAM NAME: Customer For Loop # DATE WRITTEN: June 10, 2019 # PURPOSE: Demonstrate basic "For Loop" concept # ========================================================================================== # PURPOSE: Demonstrate basic "For Loop" concept # Declare Variables # Define the target or ending value # ========================================================================================== print("How many customers do you wish to process today? <enter a positive whole number> "); howMany = int(input()); # ========================================================================================== # FOR LOOP # test loop control variable # ========================================================================================== for count in range(1, howMany + 1, 1): print("<Enter the customer's full name> "); customerName = input() print("Enter the purchase amount of the customer < enter numerical values only> :"); purchaseAmount = float(input()); print("=" * 90); print(customerName + "'s Purchase Amount is $ " + format(purchaseAmount, ",.2f")); print("=" * 90); print("THIS PROGRAM IS COMPLETE."); # ========================================================================================== # END PROGRAM # PROGRAM NAME: Customer While Loop # DATE WRITTEN: June 10, 2019 # PURPOSE: Demonstrate basic "While Loop" concept # ========================================================================================== # Declare Variables # answer is the lcv # Initialize the lcv answer # ========================================================================================== print("Do you wish to enter a customer's information? <type 'Y' or 'y'> [otherwise type 'no'] "); answer = input(); # ========================================================================================== # While Loop # test loop control variable while answer == "Y" or answer == "y": # INPUT STATEMENTS print("<Enter the customer's full name> "); customerName = input() print("Enter the purchase amount of the customer:"); purchaseAmount = float(input()); # OUTPUT STATEMENTS print("=" * 90) print(customerName + "'s Purchase Amount is $ " + format(purchaseAmount, ",.2f")); print("=" * 90) print("Do you wish to enter a customer's information? <type 'Y' or 'y'> [otherwise type 'no'] "); answer = input(); # Output the results print("=" * 90); print("Thank you for the customer information") print("=" * 90); # ========================================================================================== # END PROGRAM Exam
1 2 3 4 5 6 7 8 9 10 Midterm 1
2 Final Exam 1
2
Graded Program Assignment 1 2 3 4 5 6 7 8 9 Python Compiler |
Home |
Accounting & Finance | Business |
Computer Science | General Studies | Math | Sciences |
Civics Exam |
Everything
Else |
Help & Support |
Join/Cancel |
Contact Us |
Login / Log Out |