Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Python coding help with step 2-5 please This function is very similar to the one you wrote above however it is extracting topping two from

Python coding help with step 2-5 please

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

This function is very similar to the one you wrote above however it is extracting topping two from the string. You will need to figure out the indexes to extract a 9-letter topping. You won't start at index 0 this time because you don't want topping 1. What index will you need to start at? You need the index where the letter ' p ' is at. Then you will have to count and stop at where the comma is at (remember that index is exclusive - meaning it won't be included in the string). Create your own test for this function using this string: "cheese, pepperoni, 3000" If you did it correctly, pepperoni should be the only thing returned. Oh no! The pizza price got turned into cents while being sent to the kitchen! You need to convert the price back to dollars. For the get_price() function, use casting to convert a string value to an int, divide it by 100 and return it. Hint: Here is the general formula for converting from cents to dollars cents/100=Dollars Note: Don't forget you will need to use string slicing to extract the price from the string! (The price will always be 4 string characte Create your own test for this function using this string: "cheese, pepperoni, 3000 " The value you should see should be 30 . Too Much Cheese! (Step 4) This function returns True or False depending on if there is cheese in the order. Remember cheese can only be topping one because it is 5 letters. You will have to call the get_topping_one function and if that value is equal to cheese, return True. Otherwise, return False. In case you forgot how to call functions inside of functions, here is an example: def appleCount(numApples): \# helper function total += numApples return total def findTotalApples(): totalApples = applecount(numApples) \# creating a variable and assigning it to total from the helper function Hint: Pass the pizza_order parameter into get_topping_one when calling the function Now we are putting all the steps together. You will need to write a series of if/elif/else statements to meet the following criteria: 1. if too_much_cheese returns True, return "That's a lot of cheese!" 2. if too_much_cheese returns False AND get_price returns 45 return "Wow that's an expensive pizza!" 3. if get_topping_two returns pineapple return "Pineapple DOES belong on pizza." 4. elif get_topping_two returns artichoke return "That's an interesting combo." 5. if get_price is less than 12 OR greater than or equal to 50 return "Are we sure they're charging us right?" 6. else return "Now that's a smokin' deal! Give me more!" Hint: You will need to call the other functions you completed in prior steps Hint: Pay close attention to the wording given to determine if you need if, elif, or else \begin{tabular}{l|l} 10 & \# STEP 2 \\ 11 & def get_topping_two(pizza_order): \\ 12 & return \\ 13 & \\ 14 & \\ 15 & \# STEP 3 \\ 16 & def get_price(pizza_order): \\ 17 & return \\ 18 & \\ 19 & \\ 20 & \# STEP 4 \\ 21 & def too_much_cheese(pizza_order): \\ 22 & return \\ 23 & \\ 24 & \\ 25 & \# STEP 5 \\ 26 & def full_order(pizza_order): \\ 77 & motumn \end{tabular} \begin{tabular}{l|l} 22 & return \\ 23 & \\ 24 & \\ 25 & \# STEP 5 \\ 26 & def full_order(pizza_order): \\ 27 & return \\ 28 & \\ 29 & \\ 30 & def run(): \\ 31 & \#print(get_topping_one("cheese, pepperoni, 3000")) \\ 32 & \#print(get_topping_one("olives, pepperoni, 3000")) \\ 33 & \#create your own tests here \\ 34 & return \# make sure this line is last \\ 35 & \\ 36 & if name__= "_- main_" \\ 37 & run() \end{tabular}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Time Series Databases New Ways To Store And Access Data

Authors: Ted Dunning, Ellen Friedman

1st Edition

1491914726, 978-1491914724

More Books

Students also viewed these Databases questions