ITS 320_ Basic Programming home

pdf

School

National University College *

*We aren’t endorsed by this school

Course

320

Subject

Computer Science

Date

Jan 9, 2024

Type

pdf

Pages

31

Uploaded by praveshfiji

Report
16.1 Information for teachers using zyLabs This section's content is not available for print. 16.2 zyLab training: Basics (Python 3) While the zyLab platform can be used without training, a bit of training may help some students avoid common issues. The assignment is to get an integer from input, and output that integer squared, ending with newline. (Note: This assignment is con±gured to have students programming directly in the zyBook. Instructors may instead require students to upload a ±le). Below is a program that's been nearly completed for you. 1. Click "Run program". The output is wrong. Sometimes a program lacking input will produce wrong output (as in this case), or no output. Remember to always pre-enter needed input. 2. Type 2 in the input box, then click "Run program", and note the output is 4. 3. Type 3 in the input box instead, run, and note the output is 6. When students are done developing their program, they can submit the program for automated grading. 1. Click the "Submit mode" tab 2. Click "Submit for grading". 3. The ±rst test case failed (as did all test cases, but focus on the ±rst test case ±rst). The highlighted arrow symbol means an ending newline was expected but is missing from your program's output. Matching output exactly, even whitespace, is often required. Change the program to output an ending newline. 1. Click on "Develop mode", and change the output statement to output a newline: print(userNumSquared, end=' ') . Type 2 in the input box and run. 2. Click on "Submit mode", click "Submit for grading", and observe that now the ±rst test case passes and 1 point was earned. The last two test cases failed, due to a bug, yielding only 1 of 3 possible points. Fix that bug. 1. Click on "Develop mode", change the program to use * rather than +, and try running with input 2 (output is 4) and 3 (output is now 9, not 6 as before). 2. Click on "Submit mode" again, and click "Submit for grading". Observe that all test cases are passed, and you've earned 3 of 3 points. 437398.3038584.qx3zqy7 LAB ACTIVITY 16.2.1: zyLab training: Basics (Python 3) 0 / 3 Run your program as often as you'd like, before submitting for grading. Below, type any needed input values in the ±rst box, then click Run program and observe the program's output in the second box. Enter program input (optional) If your code requires input values, provide them here. Input (from above) main.py (Your program) Output Program output displayed here main.py Load default template... userNum = int ( input ()) userNumSquared = userNum + userNum # Bug here; fix it when instructed print ( userNumSquared , end = ' ' ) # Output formatting issue here; fix it when instru Develop mode Submit mode Run program 1 2 3 4 ©zyBooks 01/29/23 13:22 1519292 Pravesh Charan CSUGLOBALITS320MASTER1 ©zyBooks 01/29/23 13:22 1519292 Pravesh Charan CSUGLOBALITS320MASTER1
Coding trail of your work History of your effort will appear here once you begin working on this zyLab. What is this? 16.3 zyLab training: Interleaved input / output (Python 3) Auto-graded programming assignments have numerous advantages, but have some challenges too. Students commonly struggle with realizing that example input / output provided in an assignment's speci±cation interleaves input and output, but the program should only output the output parts . If a program should double its input, an instructor might provide this example: Enter x: 5 x doubled is: 25 Students often incorrectly create a program that outputs the 5. Instead, the program should only output the output parts: Enter x: x doubled is: 25 The instructor's example is showing both the output of the program, AND the user's input to that program, assuming the program is developed in an environment where a user is interacting with a program. But the program itself doesn't output the 5 (or the newline following the 5, which occurs when the user types 5 and presses enter). Also, if the instructor con±gured the test cases to observe whitespace, then according to the above example, the program should output a newline after Enter x: (and possibly after the 25, if the instructor's test case expects that). The program below incorrectly echoes the user's input to the output. 1. Try submitting it for grading (click "Submit mode", then "Submit for grading"). Notice that the test cases fail. The ±rst test case's highlighting indicates that output 3 and newline were not expected. In the second test case, the -5 and newline were not expected. 2. Remove the code that echoes the user's input back to the output, and submit again. Now the test cases should all pass. 437398.3038584.qx3zqy7 LAB ACTIVITY 16.3.1: zyLab training: Interleaved input / output (Python 3) 0 / 2 Run your program as often as you'd like, before submitting for grading. Below, type any needed input values in the ±rst box, then click Run program and observe the program's output in the second box. Enter program input (optional) If your code requires input values, provide them here. Input (from above) main.py (Your program) Output Program output displayed here main.py Load default template... print ( 'Enter x: ' ) x = int ( input ()) print ( x ) #Student mistakenly is echo'ing the input to output to match example print ( 'x doubled is:' , ( 2 * x )) Develop mode Submit mode Run program 1 2 3 4 5 ©zyBooks 01/29/23 13:22 1519292 Pravesh Charan CSUGLOBALITS320MASTER1 ©zyBooks 01/29/23 13:22 1519292 Pravesh Charan CSUGLOBALITS320MASTER1
Coding trail of your work History of your effort will appear here once you begin working on this zyLab. What is this? 16.4 Ch 1 Warm up: Hello world (Python 3) This zyLab activity prepares a student for a full programming assignment. Warm up exercises are typically simpler and worth fewer points than a full programming assignment, and are well-suited for an in-person scheduled lab meeting or as self-practice. For each of the following steps, end the program's output with a newline. (1) Write a program that outputs the following. (Submit for 1 point). Hello world! (2) Update to output the following. (Submit again for 1 more point, so 2 points total). Hello world! How are you? (3) Finally, update to output the following. (Submit again for 1 more point, so 3 points total). Hello world! How are you? (I'm fine). Hint: The ' character is printed by the two character sequence \'. Ex: print('\'') 437398.3038584.qx3zqy7 LAB ACTIVITY 16.4.1: Ch 1 Warm up: Hello world (Python 3) 0 / 3 Run your program as often as you'd like, before submitting for grading. Below, type any needed input values in the ±rst box, then click Run program and observe the program's output in the second box. Enter program input (optional) If your code requires input values, provide them here. Input (from above) main.py (Your program) Output Program output displayed here main.py Load default template... # Type your code here Develop mode Submit mode Run program 1 ©zyBooks 01/29/23 13:22 1519292 Pravesh Charan CSUGLOBALITS320MASTER1 ©zyBooks 01/29/23 13:22 1519292 Pravesh Charan CSUGLOBALITS320MASTER1
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Coding trail of your work History of your effort will appear here once you begin working on this zyLab. What is this? 16.5 Ch 1 Warm up: Basic output with variables (Python 3) This zyLab activity prepares a student for a full programming assignment. Warm up exercises are typically simpler and worth fewer points than a full programming assignment, and are well-suited for an in-person scheduled lab meeting or as self-practice. A variable like userNum can store a value like an integer. Extend the given program to print userNum values as indicated. (Submit for 2 points). (1) Output the user's input. Note: This zyLab outputs a newline after each user-input prompt. For convenience in the examples below, the user's input value is shown on the next line, but such values don't actually appear as output when the program runs. Enter integer: 4 You entered: 4 (2) Extend to output the input squared and cubed. Hint: Compute squared as userNum * userNum. (Submit for 2 points, so 4 points total). Enter integer: 4 You entered: 4 4 squared is 16 And 4 cubed is 64 !! (3) Extend to get a second user input into userNum2. Output sum and product. (Submit for 1 point, so 5 points total). Enter integer: 4 You entered: 4 4 squared is 16 And 4 cubed is 64 !! Enter another integer: 5 4 + 5 is 9 4 * 5 is 20 437398.3038584.qx3zqy7 LAB ACTIVITY 16.5.1: Ch 1 Warm up: Basic output with variables (Python 3) 0 / 5 Run your program as often as you'd like, before submitting for grading. Below, type any needed input values in the ±rst box, then click Run program and observe the program's output in the second box. Enter program input (optional) main.py Load default template... userNum = int ( input ( 'Enter integer:\n' )) # Type your code here Develop mode Submit mode 1 2 3 ©zyBooks 01/29/23 13:22 1519292 Pravesh Charan CSUGLOBALITS320MASTER1 ©zyBooks 01/29/23 13:22 1519292 Pravesh Charan CSUGLOBALITS320MASTER1
If your code requires input values, provide them here. Input (from above) main.py (Your program) Output Program output displayed here Coding trail of your work History of your effort will appear here once you begin working on this zyLab. Run program What is this? 16.6 Ch 1 Program: ASCII art (Python 3) This zyLab activity is the traditional programming assignment, typically requiring a few hours over a week. The previous sections provide warm up exercises intended to help a student prepare for this programming assignment. (1) Output this tree. (Submit for 2 points). * *** ***** ******* *** (2) Below the tree (with two blank lines), output this cat. (Submit for 3 points, so 5 points total). /\ /\ o o = = --- Hint: A backslash \ in a string acts as an escape character, such as with a newline \n . So, to print an actual backslash, escape that backslash by prepending another backslash. Ex: The following prints a single backslash: print('\\') 437398.3038584.qx3zqy7 LAB ACTIVITY 16.6.1: Ch 1 Program: ASCII art (Python 3) 0 / 5 Run your program as often as you'd like, before submitting for grading. Below, type any needed input values in the ±rst box, then click Run program and observe the program's output in the second box. Enter program input (optional) If your code requires input values, provide them here. main.py Load default template... # Draw tree print ( ' *' ) print ( ' ***' ) # Type your code here Develop mode Submit mode 1 2 3 4 ©zyBooks 01/29/23 13:22 1519292 Pravesh Charan CSUGLOBALITS320MASTER1 ©zyBooks 01/29/23 13:22 1519292 Pravesh Charan CSUGLOBALITS320MASTER1
Input (from above) main.py (Your program) Output Program output displayed here Coding trail of your work History of your effort will appear here once you begin working on this zyLab. Run program What is this? 16.7 Ch 2 Warm up: Variables, input, and type conversion (Python 3) (1) Prompt the user to input an integer between 0 and 155, a ²oat, a character, and a string, storing each into separate variables. Then, output those four values on a single line separated by a space. (Submit for 2 points). Note: This zyLab outputs a newline after each user-input prompt. For convenience in the examples below, the user's input value is shown on the next line, but such values don't actually appear as output when the program runs. Enter integer (0 - 155): 99 Enter float: 3.77 Enter character: z Enter string: Howdy 99 3.77 z Howdy (2) Extend to also output in reverse. (Submit for 1 point, so 3 points total). Enter integer (0 - 155): 99 Enter float: 3.77 Enter character: z Enter string: Howdy 99 3.77 z Howdy Howdy z 3.77 99 (3) Extend to convert the integer to a character by using the 'chr()' function, and output that character. (Submit for 2 points, so 5 points total). Enter integer (0 - 155): 99 Enter float: 3.77 Enter character: z Enter string: Howdy 99 3.77 z Howdy Howdy z 3.77 99 99 converted to a character is c 437398.3038584.qx3zqy7 LAB ACTIVITY 16.7.1: Ch 2 Warm up: Variables, input, and type conversion (Python 3) 0 / 5 main.py Load default template... userInt = int ( input ( 'Enter integer (0 - 155):\n' )) 1 2 ©zyBooks 01/29/23 13:22 1519292 Pravesh Charan CSUGLOBALITS320MASTER1 ©zyBooks 01/29/23 13:22 1519292 Pravesh Charan CSUGLOBALITS320MASTER1
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Run your program as often as you'd like, before submitting for grading. Below, type any needed input values in the ±rst box, then click Run program and observe the program's output in the second box. Enter program input (optional) If your code requires input values, provide them here. Input (from above) main.py (Your program) Output Program output displayed here Coding trail of your work History of your effort will appear here once you begin working on this zyLab. # FIXME (1): Finish reading other items into variables, then output the four values on # FIXME (2): Output the four values in reverse # FIXME (3): Convert the integer to a characer, and output that character Develop mode Submit mode Run program What is this? 16.8 Ch 2 Program: Cooking measurement converter (Python 3) (1) Prompt the user for the number of cups of lemon juice, water, and sugar needed to make lemonade. Prompt the user to specify the number of servings the recipe yields. Output the ingredients and serving size. (Submit for 2 points). Note: This zyLab outputs a newline after each user-input prompt. For convenience in the examples below, the user's input value is shown on the next line, but such values don't actually appear as output when the program runs. Enter amount of lemon juice (in cups): 2 Enter amount of water (in cups): 16 Enter amount of agave nectar (in cups): 2.5 How many servings does this make? 6 Lemonade ingredients - yields 6.0 servings 2.0 cup(s) lemon juice 16.0 cup(s) water 2.5 cup(s) agave nectar (2) Prompt the user to specify the desired number of servings. Adjust the amounts of each ingredient accordingly, and then output the ingredients and serving size. (Submit for 4 points, so 6 points total). How many servings would you like to make? 48 Lemonade ingredients - yields 48.0 servings 16.0 cup(s) lemon juice 128.0 cup(s) water 20.0 cup(s) agave nectar 2 3 4 5 6 7 ©zyBooks 01/29/23 13:22 1519292 Pravesh Charan CSUGLOBALITS320MASTER1 ©zyBooks 01/29/23 13:22 1519292 Pravesh Charan CSUGLOBALITS320MASTER1
(3) Convert the ingredient measurements from (2) to gallons. Output the ingredients and serving size. Note: There are 16 cups in a gallon. (Submit for 2 points, so 8 points total). Lemonade ingredients - yields 48.0 servings 1.0 gallon(s) lemon juice 8.0 gallon(s) water 1.25 gallon(s) agave nectar 437398.3038584.qx3zqy7 LAB ACTIVITY 16.8.1: Ch 2 Program: Cooking measurement converter (Python 3) 0 / 8 Run your program as often as you'd like, before submitting for grading. Below, type any needed input values in the ±rst box, then click Run program and observe the program's output in the second box. Enter program input (optional) If your code requires input values, provide them here. Input (from above) main.py (Your program) Output Program output displayed here Coding trail of your work History of your effort will appear here once you begin working on this zyLab. main.py Load default template... lemonJuiceCups = float ( input ( 'Enter amount of lemon juice (in cups): \n' )) # FIXME (1): Finish reading other items into variables, then output the three ingrdient # FIXME (2): Prompt user for desired number of servings. Convert and output the ingredi # FIXME (3): Convert and output the ingredients from (2) to gallons Develop mode Submit mode Run program What is this? 16.9 Ch 2 Program: Food receipt (Python 3) Note: When accuracy is essential, ±oats are not used to represent currency due to rounding and accumulation errors. Python provides several primitives speci²cally developed to implement ²nancial applications. However, these topics are beyond the scope of this lab. (1) Prompt the user to input a food item name, price, and quantity. Output an itemized receipt. (Submit for 2 points) Note: This zyLab outputs a newline after each user-input prompt. For convenience in the examples below, the user's input value is shown on the next line, but such values don't actually appear as output when the program runs. Enter food item name: hot dog Enter item price: 2.00 Enter item quantity: 5 RECEIPT 1 2 3 4 5 6 7 8 9 ©zyBooks 01/29/23 13:22 1519292 Pravesh Charan CSUGLOBALITS320MASTER1 ©zyBooks 01/29/23 13:22 1519292 Pravesh Charan CSUGLOBALITS320MASTER1
5 hot dog @ $ 2.0 = $ 10.0 Total cost: $ 10.0 (2) Extend the program to prompt the user for a second item. Output an itemized receipt. (Submit for 2 points, so 4 points total) Enter food item name: hot dog Enter item price: 2.00 Enter item quantity: 5 RECEIPT 5 hot dog @ $ 2.0 = $ 10.0 Total cost: $ 10.0 Enter second food item name: ice cream Enter item price: 2.50 Enter item quantity: 4 RECEIPT 5 hot dog @ $ 2.0 = $ 10.0 4 ice cream @ $ 2.5 = $ 10.0 Total cost: $ 20.0 (3) Extend again to output a third receipt that adds a mandatory 15% gratuity to the total cost. Output the total cost, the cost of gratuity, and the grand total. (Submit for 3 points, so 7 points total) Enter food item name: hot dog Enter item price: 2.00 Enter item quantity: 5 RECEIPT 5 hot dog @ $ 2.0 = $ 10.0 Total cost: $ 10.0 Enter second food item name: ice cream Enter item price: 2.50 Enter item quantity: 4 RECEIPT 5 hot dog @ $ 2.0 = $ 10.0 4 ice cream @ $ 2.5 = $ 10.0 Total cost: $ 20.0 15% gratuity: $ 3.0 Total with tip: $ 23.0 437398.3038584.qx3zqy7 LAB ACTIVITY 16.9.1: Ch 2 Program: Food receipt (Python 3) 0 / 7 main.py Load default template... itemName = input ( 'Enter food item name:\n' ) # FIXME (1): Finish reading item price and quantity, then output a receipt # FIXME (2): Read in a second food item name, price, and quantity, then output a second # FIXME (3): Add a gratuity and total with tip to the second receipt 1 2 3 4 5 6 7 ©zyBooks 01/29/23 13:22 1519292 Pravesh Charan CSUGLOBALITS320MASTER1 ©zyBooks 01/29/23 13:22 1519292 Pravesh Charan CSUGLOBALITS320MASTER1
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Run your program as often as you'd like, before submitting for grading. Below, type any needed input values in the ±rst box, then click Run program and observe the program's output in the second box. Enter program input (optional) If your code requires input values, provide them here. Input (from above) main.py (Your program) Output Program output displayed here Coding trail of your work History of your effort will appear here once you begin working on this zyLab. Develop mode Submit mode Run program What is this? 16.10 Ch 3 Warm up: Creating passwords (Python 3) (1) Prompt the user to enter two words and a number, storing each into separate variables. Then, output those three values on a single line separated by a space. (Submit for 1 point) Enter favorite color: yellow Enter pet's name: Daisy Enter a number: 6 You entered: yellow Daisy 6 (2) Output two passwords using a combination of the user input. Format the passwords as shown below. (Submit for 2 points, so 3 points total). Enter favorite color: yellow Enter pet's name: Daisy Enter a number: 6 You entered: yellow Daisy 6 First password: yellow_Daisy Second password: 6yellow6 (3) Output the length of each password (the number of characters in the strings). (Submit for 2 points, so 5 points total). Enter favorite color: yellow Enter pet's name: Daisy Enter a number: 6 You entered: yellow Daisy 6 First password: yellow_Daisy Second password: 6yellow6 ©zyBooks 01/29/23 13:22 1519292 Pravesh Charan CSUGLOBALITS320MASTER1 ©zyBooks 01/29/23 13:22 1519292 Pravesh Charan CSUGLOBALITS320MASTER1
Number of characters in yellow_Daisy: 12 Number of characters in 6yellow6: 8 437398.3038584.qx3zqy7 LAB ACTIVITY 16.10.1: Ch 3 Warm up: Creating passwords (Python 3) 0 / 5 Run your program as often as you'd like, before submitting for grading. Below, type any needed input values in the ±rst box, then click Run program and observe the program's output in the second box. Enter program input (optional) If your code requires input values, provide them here. Input (from above) main.py (Your program) Output Program output displayed here Coding trail of your work History of your effort will appear here once you begin working on this zyLab. main.py Load default template... # FIXME (1): Finish reading another word and an integer into variables. # Output all the values on a single line favoriteColor = input ( 'Enter favorite color: \n' ) # FIXME (2): Output two password options password1 = favoriteColor print ( '\nFirst password:' ) # FIXME (3): Output the length of the two password options Develop mode Submit mode Run program What is this? 16.11 Ch 3 Program: Painting a wall (Python 3) (1) Prompt the user to input a wall's height and width. Calculate and output the wall's area (integer). (Submit for 2 points). Enter wall height (feet): 12 Enter wall width (feet): 15 Wall area: 180 square feet (2) Extend to also calculate and output the amount of paint in gallons needed to paint the wall (²oating point). Assume a gallon of paint covers 350 square feet. Store this value in a variable. Output the amount of paint needed using the %f conversion speci±er. (Submit for 2 points, so 4 points total). Enter wall height (feet): 12 Enter wall width (feet): 15 Wall area: 180 square feet Paint needed: 0.514286 gallons (3) Extend to also calculate and output the number of 1 gallon cans needed to paint the wall. Hint: Use a math function to round up to the nearest gallon. (Submit for 2 points, so 6 points total). 1 2 3 4 5 6 7 8 9 10 11 12 ©zyBooks 01/29/23 13:22 1519292 Pravesh Charan CSUGLOBALITS320MASTER1 ©zyBooks 01/29/23 13:22 1519292 Pravesh Charan CSUGLOBALITS320MASTER1
Enter wall height (feet): 12 Enter wall width (feet): 15 Wall area: 180 square feet Paint needed: 0.514286 gallons Cans needed: 1 can(s) (4) Extend by prompting the user for a color they want to paint the walls. Calculate and output the total cost of the paint cans depending on which color is chosen. Hint: Use a dictionary to associate each paint color with its respective cost. Red paint costs $35 per gallon can, blue paint costs $25 per gallon can, and green paint costs $23 per gallon can. (Submit for 2 points, so 8 points total). Enter wall height (feet): 12 Enter wall width (feet): 15 Wall area: 180 square feet Paint needed: 0.514286 gallons Cans needed: 1 can(s) Choose a color to paint the wall: red Cost of purchasing red paint: $35 437398.3038584.qx3zqy7 LAB ACTIVITY 16.11.1: Ch 3 Program: Painting a wall (Python 3) 0 / 8 Run your program as often as you'd like, before submitting for grading. Below, type any needed input values in the ±rst box, then click Run program and observe the program's output in the second box. Enter program input (optional) If your code requires input values, provide them here. Input (from above) main.py (Your program) Output Program output displayed here Coding trail of your work History of your effort will appear here once you begin working on this zyLab. main.py Load default template... import math # Dictionary of paint colors and cost per gallon paintColors = { 'red' : 35 , 'blue' : 25 , 'green' : 23 } # FIXME (1): Prompt user to input wall's width # Calculate and output wall area wallHeight = float ( input ( 'Enter wall height (feet):\n' )) print ( 'Wall area:' ) # FIXME (2): Calculate and output the amount of paint in gallons needed to paint the # FIXME (3): Calculate and output the number of 1 gallon cans needed to paint the wa Develop mode Submit mode Run program What is this? 16.12 Ch 4 Warm up: Automobile service cost (Python 3) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 ©zyBooks 01/29/23 13:22 1519292 Pravesh Charan CSUGLOBALITS320MASTER1 ©zyBooks 01/29/23 13:22 1519292 Pravesh Charan CSUGLOBALITS320MASTER1
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
(1) Prompt the user for an automobile service. Output the user's input. (1 pt) Ex: Enter desired auto service: Oil change You entered: Oil change (2) Output the price of the requested service. (4 pts) Ex: Enter desired auto service: Oil change You entered: Oil change Cost of oil change: $35 The program should support the following services: Oil change -- $35 Tire rotation -- $19 Car wash -- $7 If the user enters a service that is not listed above, then output the following error message: Error: Requested service is not recognized 437398.3038584.qx3zqy7 LAB ACTIVITY 16.12.1: Ch 4 Warm up: Automobile service cost (Python 3) 0 / 5 Run your program as often as you'd like, before submitting for grading. Below, type any needed input values in the ±rst box, then click Run program and observe the program's output in the second box. Enter program input (optional) If your code requires input values, provide them here. Input (from above) main.py (Your program) Out Program output displayed here Coding trail of your work History of your effort will appear here once you begin working on this zyLab. main.py Load default template... # Type your code here Develop mode Submit mode Run program What is this? 1 ©zyBooks 01/29/23 13:22 1519292 Pravesh Charan CSUGLOBALITS320MASTER1 ©zyBooks 01/29/23 13:22 1519292 Pravesh Charan CSUGLOBALITS320MASTER1
16.13 Ch 4 Program: Automobile service invoice (Python 3) (1) Output a menu of automotive services and the corresponding cost of each service. (2 pts) Ex: Davy's auto shop services Oil change -- $35 Tire rotation -- $19 Car wash -- $7 Car wax -- $12 (2) Prompt the user for two services from the menu. (2 pts) Ex: Select first service: Oil change Select second service: Car wax (3) Output an invoice for the services selected. Output the cost for each service and the total cost. (3 pts) Davy's auto shop invoice Service 1: Oil change, $35 Service 2: Car wax, $12 Total: $47 (4) Extend the program to allow the user to enter a dash (-), which indicates no service. (3 pts) Ex: Davy's auto shop services Oil change -- $35 Tire rotation -- $19 Car wash -- $7 Car wax -- $12 Select first service: Tire rotation Select second service: - Davy's auto shop invoice Service 1: Tire rotation, $19 Service 2: No service Total: $19 437398.3038584.qx3zqy7 LAB ACTIVITY 16.13.1: Ch 4 Program: Automobile service invoice (Python 3) 0 / 10 main.py Load default template... # Type your code here 1 ©zyBooks 01/29/23 13:22 1519292 Pravesh Charan CSUGLOBALITS320MASTER1 ©zyBooks 01/29/23 13:22 1519292 Pravesh Charan CSUGLOBALITS320MASTER1
Run your program as often as you'd like, before submitting for grading. Below, type any needed input values in the ±rst box, then click Run program and observe the program's output in the second box. Enter program input (optional) If your code requires input values, provide them here. Input (from above) main.py (Your program) Output Program output displayed here Coding trail of your work History of your effort will appear here once you begin working on this zyLab. Develop mode Submit mode Run program What is this? 16.14 Ch 5 Warm up: Drawing a right triangle (Python 3) This program will output a right triangle based on user speci±ed height triangle_height and symbol triangle_char. (1) The given program outputs a ±xed-height triangle using a * character. Modify the given program to output a right triangle that instead uses the user-speci±ed triangle_char character. (1 pt) (2) Modify the program to use a loop to output a right triangle of height triangle_height. The ±rst line will have one user-speci±ed character, such as % or *. Each subsequent line will have one additional user-speci±ed character until the number in the triangle's base reaches triangle_height. Output a space after each user-speci±ed character, including a line's last user-speci±ed character. (2 pts) Example output for triangle_char = % and triangle_height = 5: Enter a character: % Enter triangle height: 5 % % % % % % % % % % % % % % % 437398.3038584.qx3zqy7 LAB ACTIVITY 16.14.1: Ch 5 Warm up: Drawing a right triangle (Python 3) 0 / 3 main.py Loading latest submission... 1 ©zyBooks 01/29/23 13:22 1519292 Pravesh Charan CSUGLOBALITS320MASTER1 ©zyBooks 01/29/23 13:22 1519292 Pravesh Charan CSUGLOBALITS320MASTER1
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Run your program as often as you'd like, before submitting for grading. Below, type any needed input values in the ±rst box, then click Run program and observe the program's output in the second box. Enter program input (optional) If your code requires input values, provide them here. Input (from above) main.py (Your program) Output Program output displayed here Coding trail of your work Develop mode Submit mode Run program What is this? Retrieving signature 16.15 Ch 5 Program: Drawing a half arrow (Python 3) This program outputs a downwards facing arrow composed of a rectangle and a right triangle. The arrow dimensions are de±ned by user speci±ed arrow base height, arrow base width, and arrow head width. (1) Modify the given program to use a loop to output an arrow base of height arrow_base_height. (1 pt) (2) Modify the given program to use a loop to output an arrow base of width arrow_base_width. (1 pt) (3) Modify the given program to use a loop to output an arrow head of width arrow_head_width. (2 pts) (4) Modify the given program to only accept an arrow head width that is larger than the arrow base width. Use a loop to continue prompting the user for an arrow head width until the value is larger than the arrow base width. (1 pt) while arrow_head_width <= arrow_base_width: arrow_head_width = int(input('Enter arrow head width:\n')) Example output for arrow_base_height = 5, arrow_base_width = 2, and arrow_head_width = 4: Enter arrow base height: 5 Enter arrow base width: 2 Enter arrow head width: 4 ** ** ** ** ** **** *** ©zyBooks 01/29/23 13:22 1519292 Pravesh Charan CSUGLOBALITS320MASTER1 ©zyBooks 01/29/23 13:22 1519292 Pravesh Charan CSUGLOBALITS320MASTER1
** * 437398.3038584.qx3zqy7 LAB ACTIVITY 16.15.1: Ch 5 Program: Drawing a half arrow (Python 3) 0 / 5 Run your program as often as you'd like, before submitting for grading. Below, type any needed input values in the ±rst box, then click Run program and observe the program's output in the second box. Enter program input (optional) If your code requires input values, provide them here. Input (from above) main.py (Your program) Output Program output displayed here Coding trail of your work main.py Loading latest submission... Develop mode Submit mode Run program What is this? Retrieving signature 16.16 Ch 6 Warm up: Text analyzer & modi±er (Python 3) (1) Prompt the user to enter a string of their choosing. Output the string. (1 pt) Ex: Enter a sentence or phrase: The only thing we have to fear is fear itself. You entered: The only thing we have to fear is fear itself. (2) Complete the get_num_of_characters() function, which returns the number of characters in the user's string. We encourage you to use a for loop in this function. (2 pts) (3) Extend the program by calling the get_num_of_characters() function and then output the returned result. (1 pt) (4) Extend the program further by implementing the output_without_whitespace() function. output_without_whitespace() outputs the string's characters except for whitespace (spaces, tabs). Note: A tab is '\t'. Call the output_without_whitespace() function in main(). (2 pts) Ex: Enter a sentence or phrase: The only thing we have to fear is fear itself. You entered: The only thing we have to fear is fear itself. Number of characters: 46 String with no whitespace: Theonlythingwehavetofearisfearitself. 1 ©zyBooks 01/29/23 13:22 1519292 Pravesh Charan CSUGLOBALITS320MASTER1 ©zyBooks 01/29/23 13:22 1519292 Pravesh Charan CSUGLOBALITS320MASTER1
437398.3038584.qx3zqy7 LAB ACTIVITY 16.16.1: Ch 6 Warm up: Text analyzer & modi±er (Python 3) 0 / 6 Run your program as often as you'd like, before submitting for grading. Below, type any needed input values in the ±rst box, then click Run program and observe the program's output in the second box. Enter program input (optional) If your code requires input values, provide them here. Input (from above) main.py (Your program) Output Program output displayed here Coding trail of your work History of your effort will appear here once you begin working on this zyLab. main.py Load default template... def get_num_of_characters ( inputStr ): # Type your code here return if __name__ == '__main__' : # Type your code here Develop mode Submit mode Run program What is this? 16.17 Ch 6 Program: Authoring assistant (Python 3) (1) Prompt the user to enter a string of their choosing. Store the text in a string. Output the string. (1 pt) Ex: Enter a sample text: we'll continue our quest in space. there will be more shuttle flights and more shuttle crews and, yes; more volunteers, more civilians, more teachers in space. nothing ends here; our hopes and our journeys continue! You entered: we'll continue our quest in space. there will be more shuttle flights and more shuttle crews and, yes; more volunteers, more civilians, more teachers in space. nothing ends here; our hopes and our journeys continue! (2) Implement a print_menu() function, which has a string as a parameter, outputs a menu of user options for analyzing/editing the string, and returns the user's entered menu option and the sample text string (which can be edited inside the print_menu() function). Each option is represented by a single character. If an invalid character is entered, continue to prompt for a valid choice. Hint: Implement the Quit menu option before implementing other options. Call print_menu() in the main section of your code. Continue to call print_menu() until the user enters q to Quit. (3 pts) Ex: MENU c - Number of non-whitespace characters w - Number of words f - Fix capitalization r - Replace punctuation 1 2 3 4 5 6 7 ©zyBooks 01/29/23 13:22 1519292 Pravesh Charan CSUGLOBALITS320MASTER1 ©zyBooks 01/29/23 13:22 1519292 Pravesh Charan CSUGLOBALITS320MASTER1
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
s - Shorten spaces q - Quit Choose an option: (3) Implement the get_num_of_non_WS_characters() function. get_num_of_non_WS_characters() has a string parameter and returns the number of characters in the string, excluding all whitespace. Call get_num_of_non_WS_characters() in the print_menu() function. (4 pts) Ex: Number of non-whitespace characters: 181 (4) Implement the get_num_of_words() function. get_num_of_words() has a string parameter and returns the number of words in the string. Hint: Words end when a space is reached except for the last word in a sentence. Call get_num_of_words() in the print_menu() function. (3 pts) Ex: Number of words: 35 (5) Implement the ±x_capilization() function. ±x_capilization() has a string parameter and returns an updated string, where lowercase letters at the beginning of sentences are replaced with uppercase letters. ±x_capilization() also returns the number of letters that have been capitalized. Call ±x_capilization() in the print_menu() function, and then output the number of letters capitalized and the edited string. Hint 1: Look up and use Python functions .islower() and .upper() to complete this task. Hint 2: Create an empty string and use string concatenation to make edits to the string. (3 pts) Ex: Number of letters capitalized: 3 Edited text: We'll continue our quest in space. There will be more shuttle flights and more shuttle crews and, yes; more volunteers, more civilians, more teachers in space. Nothing ends here; our hopes and our journeys continue! (6) Implement the replace_punctuation() function. replace_punctuation() has a string parameter and two keyword argument parameters exclamationCount and semicolonCount . replace_punctuation() updates the string by replacing each exclamation point (!) character with a period (.) and each semicolon (;) character with a comma (,). replace_punctuation() also counts the number of times each character is replaced and outputs those counts. Lastly, replace_punctuation() returns the updated string. Call replace_exclamation() in the print_menu() function, and then output the edited string. (3 pts) Ex: Punctuation replaced exclamationCount: 1 semicolonCount: 2 Edited text: we'll continue our quest in space. there will be more shuttle flights and more shuttle crews and, yes, more volunteers, more civilians, more teachers in space. nothing ends here, our hopes and our journeys continue. (7) Implement the shorten_space() function. shorten_space() has a string parameter and updates the string by replacing all sequences of 2 or more spaces with a single space. shorten_space() returns the string. Call shorten_space() in the print_menu() function, and then output the edited string. Hint: Look up and use Python function .isspace(). (3 pt) Ex: Edited text: we'll continue our quest in space. there will be more shuttle flights and more shuttle crews and, yes, more volunteers, more civilians, more teachers in space. nothing ends here; our hopes and our journeys continue! 437398.3038584.qx3zqy7 LAB ACTIVITY 16.17.1: Ch 6 Program: Authoring assistant (Python 3) 0 / 20 main.py Loading latest submission... 1 ©zyBooks 01/29/23 13:22 1519292 Pravesh Charan CSUGLOBALITS320MASTER1 ©zyBooks 01/29/23 13:22 1519292 Pravesh Charan CSUGLOBALITS320MASTER1
Run your program as often as you'd like, before submitting for grading. Below, type any needed input values in the ±rst box, then click Run program and observe the program's output in the second box. Enter program input (optional) If your code requires input values, provide them here. Input (from above) main.py (Your program) Output Program output displayed here Coding trail of your work Develop mode Submit mode Run program What is this? Retrieving signature 16.18 Ch 7 Warm up: Parsing strings (Python 3) (1) Prompt the user for a string that contains two strings separated by a comma. (1 pt) Examples of strings that can be accepted: Jill, Allen Jill , Allen Jill,Allen Ex: Enter input string: Jill, Allen (2) Report an error if the input string does not contain a comma. Continue to prompt until a valid string is entered. Note: If the input contains a comma, then assume that the input also contains two strings. (2 pts) Ex: Enter input string: Jill Allen Error: No comma in string. Enter input string: Jill, Allen (3) Using string splitting, extract the two words from the input string and then remove any spaces. Output the two words. (2 pts) Ex: Enter input string: Jill, Allen First word: Jill Second word: Allen (4) Using a loop, extend the program to handle multiple lines of input. Continue until the user enters q to quit. (2 pts) Ex: Enter input string: Jill, Allen First word: Jill Second word: Allen ©zyBooks 01/29/23 13:22 1519292 Pravesh Charan CSUGLOBALITS320MASTER1 ©zyBooks 01/29/23 13:22 1519292 Pravesh Charan CSUGLOBALITS320MASTER1
Enter input string: Golden , Monkey First word: Golden Second word: Monkey Enter input string: Washington,DC First word: Washington Second word: DC Enter input string: q 437398.3038584.qx3zqy7 LAB ACTIVITY 16.18.1: Ch 7 Warm up: Parsing strings (Python 3) 0 / 7 Run your program as often as you'd like, before submitting for grading. Below, type any needed input values in the ±rst box, then click Run program and observe the program's output in the second box. Enter program input (optional) If your code requires input values, provide them here. Input (from above) main.py (Your program) Output Program output displayed here Coding trail of your work main.py Loading latest submission... Develop mode Submit mode Run program What is this? Retrieving signature 16.19 Ch 7 Program: Data visualization (Python 3) (1) Prompt the user for a title for data. Output the title. (1 pt) Ex: Enter a title for the data: Number of Novels Authored You entered: Number of Novels Authored (2) Prompt the user for the headers of two columns of a table. Output the column headers. (1 pt) Ex: 1 ©zyBooks 01/29/23 13:22 1519292 Pravesh Charan CSUGLOBALITS320MASTER1 ©zyBooks 01/29/23 13:22 1519292 Pravesh Charan CSUGLOBALITS320MASTER1
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Enter the column 1 header: Author name You entered: Author name Enter the column 2 header: Number of novels You entered: Number of novels (3) Prompt the user for data points. Data points must be in this format: string, int . Store the information before the comma into a string variable and the information after the comma into an integer. The user will enter -1 when they have ±nished entering data points. Output the data points. Store the string components of the data points in a list of strings. Store the integer components of the data points in a list of integers. (4 pts) Ex: Enter a data point (-1 to stop input): Jane Austen, 6 Data string: Jane Austen Data integer: 6 (4) Perform error checking for the data point entries. If any of the following errors occurs, output the appropriate error message and prompt again for a valid data point. If entry has no comma Output: Error: No comma in string. (1 pt) If entry has more than one comma Output: Error: Too many commas in input. (1 pt) If entry after the comma is not an integer Output: Error: Comma not followed by an integer. (2 pts) Ex: Enter a data point (-1 to stop input): Ernest Hemingway 9 Error: No comma in string. Enter a data point (-1 to stop input): Ernest, Hemingway, 9 Error: Too many commas in input. Enter a data point (-1 to stop input): Ernest Hemingway, nine Error: Comma not followed by an integer. Enter a data point (-1 to stop input): Ernest Hemingway, 9 Data string: Ernest Hemingway Data integer: 9 (5) Output the information in a formatted table. The title is right justi±ed with a minimum ±eld width value of 33. Column 1 has a minimum ±eld width value of 20. Column 2 has a minimum ±eld width value of 23. (3 pts) Ex: Number of Novels Authored Author name | Number of novels -------------------------------------------- Jane Austen | 6 Charles Dickens | 20 Ernest Hemingway | 9 Jack Kerouac | 22 F. Scott Fitzgerald | 8 Mary Shelley | 7 Charlotte Bronte | 5 Mark Twain | 11 Agatha Christie | 73 Ian Flemming | 14 J.K. Rowling | 14 Stephen King | 54 Oscar Wilde | 1 ©zyBooks 01/29/23 13:22 1519292 Pravesh Charan CSUGLOBALITS320MASTER1 ©zyBooks 01/29/23 13:22 1519292 Pravesh Charan CSUGLOBALITS320MASTER1
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
(6) Output the information as a formatted histogram. Each name is right justi±ed with a minimum ±eld width value of 20. (4 pts) Ex: Jane Austen ****** Charles Dickens ******************** Ernest Hemingway ********* Jack Kerouac ********************** F. Scott Fitzgerald ******** Mary Shelley ******* Charlotte Bronte ***** Mark Twain *********** Agatha Christie ************************************************************************* Ian Flemming ************** J.K. Rowling ************** Stephen King ****************************************************** Oscar Wilde * 437398.3038584.qx3zqy7 LAB ACTIVITY 16.19.1: Ch 7 Program: Data visualization (Python 3) 0 / 17 Run your program as often as you'd like, before submitting for grading. Below, type any needed input values in the ±rst box, then click Run program and observe the program's output in the second box. Enter program input (optional) If your code requires input values, provide them here. Input (from above) main.py (Your program) Output Program output displayed here Coding trail of your work main.py Loading latest submission... Develop mode Submit mode Run program What is this? Retrieving signature 16.20 Ch 8 Warm up: People's weights (Lists) (Python 3) (1) Prompt the user to enter four numbers, each corresponding to a person's weight in pounds. Store all weights in a list. Output the list. (2 pts) Ex: Enter weight 1: 236.0 Enter weight 2: 1 ©zyBooks 01/29/23 13:22 1519292 Pravesh Charan CSUGLOBALITS320MASTER1 ©zyBooks 01/29/23 13:22 1519292 Pravesh Charan CSUGLOBALITS320MASTER1
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
89.5 Enter weight 3: 176.0 Enter weight 4: 166.3 Weights: [236.0, 89.5, 176.0, 166.3] (2) Output the average of the list's elements with two digits after the decimal point. Hint: Use a conversion speci²er to output with a certain number of digits after the decimal point. (1 pt) (3) Output the max list element with two digits after the decimal point. (1 pt) Ex: Enter weight 1: 236.0 Enter weight 2: 89.5 Enter weight 3: 176.0 Enter weight 4: 166.3 Weights: [236.0, 89.5, 176.0, 166.3] Average weight: 166.95 Max weight: 236.00 (4) Prompt the user for a number between 1 and 4. Output the weight at the user speci±ed location and the corresponding value in kilograms. 1 kilogram is equal to 2.2 pounds. (3 pts) Ex: Enter a list index location (0 - 3): 3 Weight in pounds: 176.00 Weight in kilograms: 80.00 (5) Sort the list's elements from least heavy to heaviest weight. (2 pts) Ex: Sorted list: [89.5, 166.3, 176.0, 236.0] 437398.3038584.qx3zqy7 LAB ACTIVITY 16.20.1: Ch 8 Warm up: People's weights (Lists) (Python 3) 0 / 9 Run your program as often as you'd like, before submitting for grading. Below, type any needed input values in the ±rst box, then click Run program and observe the program's output in the second box. Enter program input (optional) If your code requires input values, provide them here. main.py Loading latest submission... Develop mode Submit mode 1 ©zyBooks 01/29/23 13:22 1519292 Pravesh Charan CSUGLOBALITS320MASTER1 ©zyBooks 01/29/23 13:22 1519292 Pravesh Charan CSUGLOBALITS320MASTER1
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Input (from above) main.py (Your program) Output Program output displayed here Coding trail of your work Run program What is this? Retrieving signature 16.21 Ch 8 Program: Soccer team roster (Dictionaries) (Python 3) This program will store roster and rating information for a soccer team. Coaches rate players during tryouts to ensure a balanced team. (1) Prompt the user to input ±ve pairs of numbers: A player's jersey number (0 - 99) and the player's rating (1 - 9). Store the jersey numbers and the ratings in a dictionary. Output the dictionary's elements with the jersey numbers in ascending order (i.e., output the roster from smallest to largest jersey number). Hint: Dictionary keys can be stored in a sorted list. (3 pts) Ex: Enter player 1's jersey number: 84 Enter player 1's rating: 7 Enter player 2's jersey number: 23 Enter player 2's rating: 4 Enter player 3's jersey number: 4 Enter player 3's rating: 5 Enter player 4's jersey number: 30 Enter player 4's rating: 2 Enter player 5's jersey number: 66 Enter player 5's rating: 9 ROSTER Jersey number: 4, Rating: 5 Jersey number: 23, Rating: 4 Jersey number 30, Rating: 2 ... (2) Implement a menu of options for a user to modify the roster. Each option is represented by a single character. The program initially outputs the menu, and outputs the menu after a user chooses an option. The program ends when the user chooses the option to Quit. For this step, the other options do nothing. (2 pts) Ex: MENU a - Add player d - Remove player u - Update player rating r - Output players above a rating o - Output roster q - Quit Choose an option: (3) Implement the "Output roster" menu option. (1 pt) ©zyBooks 01/29/23 13:22 1519292 Pravesh Charan CSUGLOBALITS320MASTER1 ©zyBooks 01/29/23 13:22 1519292 Pravesh Charan CSUGLOBALITS320MASTER1
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Ex: ROSTER Jersey number: 4, Rating: 5 Jersey number: 23, Rating: 4 Jersey number 30, Rating: 2 ... (4) Implement the "Add player" menu option. Prompt the user for a new player's jersey number and rating. Append the values to the two vectors. (1 pt) Ex: Enter a new player's jersey number: 49 Enter the player's rating: 8 (5) Implement the "Delete player" menu option. Prompt the user for a player's jersey number. Remove the player from the roster (delete the jersey number and rating). (1 pt) Ex: Enter a jersey number: 4 (6) Implement the "Update player rating" menu option. Prompt the user for a player's jersey number. Prompt again for a new rating for the player, and then change that player's rating. (1 pt) Ex: Enter a jersey number: 23 Enter a new rating for player: 6 (7) Implement the "Output players above a rating" menu option. Prompt the user for a rating. Print the jersey number and rating for all players with ratings above the entered value. (2 pts) Ex: Enter a rating: 5 ABOVE 5 Jersey number: 66, Rating: 9 Jersey number: 84, Rating: 7 ... 437398.3038584.qx3zqy7 LAB ACTIVITY 16.21.1: Ch 8 Program: Soccer team roster (Dictionaries) (Python 3) 0 / 11 Run your program as often as you'd like, before submitting for grading. Below, type any needed input values in the ±rst box, then click Run program and observe the program's output in the second box. Enter program input (optional) main.py Loading latest submission... Develop mode Submit mode 1 ©zyBooks 01/29/23 13:22 1519292 Pravesh Charan CSUGLOBALITS320MASTER1 ©zyBooks 01/29/23 13:22 1519292 Pravesh Charan CSUGLOBALITS320MASTER1
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
If your code requires input values, provide them here. Input (from above) main.py (Your program) Output Program output displayed here Coding trail of your work Run program What is this? Retrieving signature 16.22 Ch 9 Warm up: Online shopping cart (Python3) (1) Build the ItemToPurchase class with the following speci±cations: Attributes (3 pts) item_name (string) item_price (²oat) item_quantity (int) Default constructor (1 pt) Initializes item's name = "none", item's price = 0, item's quantity = 0 Method print_item_cost() Ex. of print_item_cost() output: Bottled Water 10 @ $1 = $10 (2) In the main section of your code, prompt the user for two items and create two objects of the ItemToPurchase class. (2 pts) Ex: Item 1 Enter the item name: Chocolate Chips Enter the item price: 3 Enter the item quantity: 1 Item 2 Enter the item name: Bottled Water Enter the item price: 1 Enter the item quantity: 10 (3) Add the costs of the two items together and output the total cost. (2 pts) Ex: TOTAL COST Chocolate Chips 1 @ $3 = $3 Bottled Water 10 @ $1 = $10 Total: $13 437398.3038584.qx3zqy7 LAB ACTIVITY 16.22.1: Ch 9 Warm up: Online shopping cart (Python3) 0 / 8 main.py ©zyBooks 01/29/23 13:22 1519292 Pravesh Charan CSUGLOBALITS320MASTER1 ©zyBooks 01/29/23 13:22 1519292 Pravesh Charan CSUGLOBALITS320MASTER1
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Run your program as often as you'd like, before submitting for grading. Below, type any needed input values in the ±rst box, then click Run program and observe the program's output in the second box. Enter program input (optional) If your code requires input values, provide them here. Input (from above) main.py (Your program) Output Program output displayed here Coding trail of your work Loading latest submission... Develop mode Submit mode Run program What is this? Retrieving signature 16.23 Ch 9 Program: Online shopping cart (continued) (Python 3) This program extends the earlier "Online shopping cart" program. (Consider ±rst saving your earlier program). (1) Extend the ItemToPurchase class to contain a new attribute. (2 pts) item_description (string) - Set to "none" in default constructor Implement the following method for the ItemToPurchase class. print_item_description() - Prints item_description attribute for an ItemToPurchase object. Has an ItemToPurchase parameter. Ex. of print_item_description() output: Bottled Water: Deer Park, 12 oz. (2) Build the ShoppingCart class with the following data attributes and related methods. Note: Some can be method stubs (empty methods) initially, to be completed in later steps. Parameterized constructor which takes the customer name and date as parameters (2 pts) Attributes customer_name (string) - Initialized in default constructor to "none" current_date (string) - Initialized in default constructor to "January 1, 2016" cart_items (list) Methods add_item() Adds an item to cart_items list. Has parameter ItemToPurchase. Does not return anything. remove_item() Removes item from cart_items list. Has a string (an item's name) parameter. Does not return anything. If item name cannot be found, output this message: Item not found in cart. Nothing removed. modify_item() Modi±es an item's description, price, and/or quantity. Has parameter ItemToPurchase. Does not return anything. If item can be found (by name) in cart, check if parameter has default values for description, price, and quantity. If not, modify item in cart. If item cannot be found (by name) in cart, output this message: Item not found in cart. Nothing modified. 1 ©zyBooks 01/29/23 13:22 1519292 Pravesh Charan CSUGLOBALITS320MASTER1 ©zyBooks 01/29/23 13:22 1519292 Pravesh Charan CSUGLOBALITS320MASTER1
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
get_num_items_in_cart() (2 pts) Returns quantity of all items in cart. Has no parameters. get_cost_of_cart() (2 pts) Determines and returns the total cost of items in cart. Has no parameters. print_total() Outputs total of objects in cart. If cart is empty, output this message: SHOPPING CART IS EMPTY print_descriptions() Outputs each item's description. Ex. of print_total() output: John Doe's Shopping Cart - February 1, 2016 Number of Items: 8 Nike Romaleos 2 @ $189 = $378 Chocolate Chips 5 @ $3 = $15 Powerbeats 2 Headphones 1 @ $128 = $128 Total: $521 Ex. of print_descriptions() output: John Doe's Shopping Cart - February 1, 2016 Item Descriptions Nike Romaleos: Volt color, Weightlifting shoes Chocolate Chips: Semi-sweet Powerbeats 2 Headphones: Bluetooth headphones (3) In main section of your code, prompt the user for a customer's name and today's date. Output the name and date. Create an object of type ShoppingCart. (1 pt) Ex. Enter customer's name: John Doe Enter today's date: February 1, 2016 Customer name: John Doe Today's date: February 1, 2016 (4) Implement the print_menu() function. print_menu() has a ShoppingCart parameter, and outputs a menu of options to manipulate the shopping cart. Each option is represented by a single character. Build and output the menu within the function. If the an invalid character is entered, continue to prompt for a valid choice. Hint: Implement Quit before implementing other options. Call print_menu() in the main() function. Continue to execute the menu until the user enters q to Quit. (3 pts) Ex: MENU a - Add item to cart r - Remove item from cart c - Change item quantity i - Output items' descriptions o - Output shopping cart q - Quit Choose an option: (5) Implement Output shopping cart menu option. (3 pts) Ex: OUTPUT SHOPPING CART John Doe's Shopping Cart - February 1, 2016 Number of Items: 8 Nike Romaleos 2 @ $189 = $378 Chocolate Chips 5 @ $3 = $15 ©zyBooks 01/29/23 13:22 1519292 Pravesh Charan CSUGLOBALITS320MASTER1 ©zyBooks 01/29/23 13:22 1519292 Pravesh Charan CSUGLOBALITS320MASTER1
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Powerbeats 2 Headphones 1 @ $128 = $128 Total: $521 (6) Implement Output item's description menu option. (2 pts) Ex. OUTPUT ITEMS' DESCRIPTIONS John Doe's Shopping Cart - February 1, 2016 Item Descriptions Nike Romaleos: Volt color, Weightlifting shoes Chocolate Chips: Semi-sweet Powerbeats 2 Headphones: Bluetooth headphones (7) Implement Add item to cart menu option. (3 pts) Ex: ADD ITEM TO CART Enter the item name: Nike Romaleos Enter the item description: Volt color, Weightlifting shoes Enter the item price: 189 Enter the item quantity: 2 (8) Implement remove item menu option. (4 pts) Ex: REMOVE ITEM FROM CART Enter name of item to remove: Chocolate Chips (9) Implement Change item quantity menu option. Hint: Make new ItemToPurchase object before using ModifyItem() method. (5 pts) Ex: CHANGE ITEM QUANTITY Enter the item name: Nike Romaleos Enter the new quantity: 3 437398.3038584.qx3zqy7 LAB ACTIVITY 16.23.1: Ch 9 Program: Online shopping cart (continued) (Python 3) 0 / 29 main.py Load default template... # Type code here 1 ©zyBooks 01/29/23 13:22 1519292 Pravesh Charan CSUGLOBALITS320MASTER1 ©zyBooks 01/29/23 13:22 1519292 Pravesh Charan CSUGLOBALITS320MASTER1
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Run your program as often as you'd like, before submitting for grading. Below, type any needed input values in the ±rst box, then click Run program and observe the program's output in the second box. Enter program input (optional) If your code requires input values, provide them here. Input (from above) main.py (Your program) Output Program output displayed here Coding trail of your work History of your effort will appear here once you begin working on this zyLab. Develop mode Submit mode Run program What is this? ©zyBooks 01/29/23 13:22 1519292 Pravesh Charan CSUGLOBALITS320MASTER1 ©zyBooks 01/29/23 13:22 1519292 Pravesh Charan CSUGLOBALITS320MASTER1
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help