You are on page 1of 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