0% found this document useful (0 votes)
32 views1 page

Lab 11 S 13

This document provides instructions for writing a Python program with three functions: get_data(), change(), and print_lists(). Get_data() populates two lists - fruits and prices - by prompting the user to enter a fruit name and price until "Stop" is entered. It returns the two lists. Change() prompts the user to select a fruit to change the price of, validates the input, gets the new price, updates the price list, and calls print_lists(). Print_lists() prints the fruit name and price from the two lists passed to it in a formatted way. The main() function calls the other functions in the order get_data(), print_lists(),

Uploaded by

jburn4
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views1 page

Lab 11 S 13

This document provides instructions for writing a Python program with three functions: get_data(), change(), and print_lists(). Get_data() populates two lists - fruits and prices - by prompting the user to enter a fruit name and price until "Stop" is entered. It returns the two lists. Change() prompts the user to select a fruit to change the price of, validates the input, gets the new price, updates the price list, and calls print_lists(). Print_lists() prints the fruit name and price from the two lists passed to it in a formatted way. The main() function calls the other functions in the order get_data(), print_lists(),

Uploaded by

jburn4
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

Lab 11

Name_________________________
Write a program named Lab11.py which will ask for the name of a fruit and the price of each item. Write a Python program with three functions: get_data: a) Declare two lists: fruits and prices b) Populate the fruits list by asking the user for the fruit. c) Populate the price list by asking the user for prices. d) Use the append function for the above. e) Keep doing the above until the user enters Stop when asked for a fruit. f) Return both lists. change: a) Ask user for a fruits name. b) Use a while validation loop to ensure the fruit specified is in the list. Require user to re-enter if the entry is not in the list. c) If the fruit is in the list: i. Print The price of orange is $1.25. ii. Ask what the new price should be. iii. Change the price. iv. Call print_lists. d) You will need to use the in operator and the index method for this. e) Use a while loop to ask the user if there are more price changes. print_lists: a) Has two parameters: both lists. b) Prints the name and price for each fruit where the name takes a minimum of 10 spaces and the price and the name are separated by two tabs. main() : a) Calls get_data. b) Calls print_lists, passing the lists. c) Calls change, passing the lists.

Make sure you use comments to describe the program and the functions. Attach your finished program to Blackboard

You might also like