Knowee
Questions
Features
Study Tools

Option 1: LIST WITH PLACEHOLDERS Create a List with Placeholders to Define the Order and Data Types Expected - Remember, each data element in your list has a specific position. That position is its index number. The index number comes from the order they are in the list. - However, each data element in the list could actually be a different data type. - For example, the information at index 0 could be a string like "chicken" or "beef", or it could be an integer like 2 or 3 to describe the number of ketchup packets at index 3. - By using strings and variables in the actual list, this option will provide flexibility down the road. - Set up the list to expect variables, strings, and integers in the list; create an index spot for each menu item to become an element in the list. - Create a list using empty strings for each future sandwich, beverage, and fries choice. - The empty string tells the program to expect a string to be placed into the list at that index position. - At index 3, however, place a 0 to indicate that an integer is expected (number of ketchup packets). Starter code you might add to as you work looks like this: order = ["", "", "", 0] sandwich_index = 0 beverage_index = 1 fries_index = 2 ketchup_index = 3 Using the example code provided, you would need to outline your list and add code to add items at specific index positions. # Iteration 1 Code sandwich_choice = input('What kind of sandwich would you like - enter c for chicken $5.25, b for beef $6.25, t for tofu $5.75 ') #print('Sandwich:', sandwich_choice) if sandwich_choice == 'c' or sandwich_choice == "C": total_cost += 5.25 print('Sandwich: Chicken $5.25') elif sandwich_choice == 'b': total_cost += 6.25 print('Sandwich: Beef $6.25') else: total_cost += 5.75 print('Sandwich: Tofu $5.75') # Iteration 2 Code beverage = input('Would you like a drink with your sandwich? Enter y or n. ') if beverage == 'y' or beverage == 'Y': beverage_choice = input('What size drink would you like? Enter s for small $1.00, m for medium $1.75, l for large $2.25 ') #print('Drink: ' + beverage_choice) if beverage_choice == 's': total_cost += 1.00 print('Drink: Small $1.00') elif beverage_choice == 'm': total_cost += 1.75 print('Drink: Medium $1.75') else: total_cost += 2.25 print('Drink: Large $2.25') else: print('No Drink') # Iteration 3 Code fries_with_that = input('Would you like fries with your order? Enter y for Yes or n for No ') if fries_with_that == 'y': fries_choice = input('What size fries would you like? Enter s for small $1.00 m for Medium $1.50 l for Large $2.00 ') if fries_choice == 's': fries_mega = input('Would you like to megasize your fries for $1.00 more? Enter y for Yes or n for No ') if fries_mega == 'y': total_cost += 2 print('Fries: Large $2.00') else: total

Question

Option 1: LIST WITH PLACEHOLDERS

Create a List with Placeholders to Define the Order and Data Types Expected

  • Remember, each data element in your list has a specific position. That position is its index number. The index number comes from the order they are in the list.

    • However, each data element in the list could actually be a different data type.
      • For example, the information at index 0 could be a string like "chicken" or "beef", or it could be an integer like 2 or 3 to describe the number of ketchup packets at index 3.
  • By using strings and variables in the actual list, this option will provide flexibility down the road.

  • Set up the list to expect variables, strings, and integers in the list; create an index spot for each menu item to become an element in the list.

    • Create a list using empty strings for each future sandwich, beverage, and fries choice.

      • The empty string tells the program to expect a string to be placed into the list at that index position.
    • At index 3, however, place a 0 to indicate that an integer is expected (number of ketchup packets).

Starter code you might add to as you work looks like this:

order = ["", "", "", 0]
sandwich_index = 0
beverage_index = 1
fries_index = 2
ketchup_index = 3

Using the example code provided, you would need to outline your list and add code to add items at specific index positions. # Iteration 1 Code sandwich_choice = input('What kind of sandwich would you like - enter c for chicken 5.25,bforbeef5.25, b for beef 6.25, t for tofu 5.75 ') #print('Sandwich:', sandwich_choice) if sandwich_choice == 'c' or sandwich_choice == "C": total_cost += 5.25 print('Sandwich: Chicken 5.25') elif sandwich_choice == 'b': total_cost += 6.25 print('Sandwich: Beef 6.25)else:totalcost+=5.75print(Sandwich:Tofu6.25') else: total_cost += 5.75 print('Sandwich: Tofu 5.75')

Iteration 2 Code

beverage = input('Would you like a drink with your sandwich? Enter y or n. ') if beverage == 'y' or beverage == 'Y': beverage_choice = input('What size drink would you like? Enter s for small 1.00,mformedium1.00, m for medium 1.75, l for large 2.25 ') #print('Drink: ' + beverage_choice) if beverage_choice == 's': total_cost += 1.00 print('Drink: Small 1.00') elif beverage_choice == 'm': total_cost += 1.75 print('Drink: Medium 1.75)else:totalcost+=2.25print(Drink:Large1.75') else: total_cost += 2.25 print('Drink: Large 2.25') else: print('No Drink')

Iteration 3 Code

fries_with_that = input('Would you like fries with your order? Enter y for Yes or n for No ') if fries_with_that == 'y': fries_choice = input('What size fries would you like? Enter s for small 1.00mforMedium1.00 m for Medium 1.50 l for Large 2.00)iffrieschoice==s:friesmega=input(Wouldyouliketomegasizeyourfriesfor2.00 ') if fries_choice == 's': fries_mega = input('Would you like to megasize your fries for 1.00 more? Enter y for Yes or n for No ') if fries_mega == 'y': total_cost += 2 print('Fries: Large $2.00') else: total

...expand
🧐 Not the exact question you are looking for?Go ask a question

Solution

I'm sorry, but you didn't provide any text for me to respond to. Could you please provide the text?

Similar Questions

A(n) _____________________ is a list collection has elements whose elements can be referenced using a numeric index. A. indexed list B. array C. ordered list D. linked list E. unordered list

List items have an index number. In the following list , which item has index number 3?["John", "Harry", "Jesse", "John", "Harry", "Harry"]A"John"B"Harry"C"Jesse"DThere is no single right answer

In the context of databases, which type of index uses a separate data structure to store index key values along with pointers to the actual data rows?OptionsB-Tree IndexHash IndexBitmap IndexDense Index

In the context of databases, which type of index uses a separate data structure to store index key values along with pointers to the actual data rows?OptionsDense IndexHash IndexB-Tree IndexBitmap Index

In the context of databases, which type of index uses a separate data structure to store index key values along with pointers to the actual data rows?OptionsB-Tree IndexBitmap IndexDense IndexHash Index

1/1

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.