Question

In: Computer Science

(In python) Write a function calc_pizza_charge that takes four integer arguments, one for the size (1...

(In python)

Write a function calc_pizza_charge that takes four integer arguments, one for the size (1 small, 2 medium, 3 large), one for the number of meat toppings, one for the number of other toppings and another for the quantity of pizzas ordered. It should calculate and return the total due for that pizza order based on the following information:

Small pizza base price: $6.50

Medium pizza base price: $9.50

Large pizza base price: $11.50

The base pizza price includes one meat and one non-meat topping.

Additional meat toppings are charged at $3.50 each.

Additional non-meat toppings are charged at $1.5 each.

Write a function get_pizza_info that gets from the user the pizza size, meat topping quantity, non-meat topping quantity and number of pizza’s ordered and calls the calc_pizza_charge method and returns the result. Write a program in problem3.py that calls get_pizza_info and prints the result formatted for currency.

Sample run: Enter pizza size (1 small, 2 medium, 3 large): 3

Enter number meat toppings: 2

Enter number or non-meat toppings: 3

Enter number of pizzas ordered: 2

Pizza Total: $36.00

Solutions

Expert Solution

==================================

def calc_pizza_charge(pizza_size,noOfMeatToppings,otherToppings,noOfPizzas):
if pizza_size==1 :
tot=6.50*noOfPizzas
elif pizza_size==2 :
tot=9.50*noOfPizzas
else:
tot=11.50*noOfPizzas
tot=tot+(noOfMeatToppings*3.50)+(otherToppings*1.50)
return tot;

def get_pizza_info():
size=int(input("Enter pizza size (1 small, 2 medium, 3 large):"))
  
meatTopp=int(input("Enter number of meat toppings: "))
otherTopp=int(input("Enter number or non-meat toppings: "))
noOfPizzas=int(input("Enter number of pizzas ordered: "))   
  
pizza_total=calc_pizza_charge(size,meatTopp,otherTopp,noOfPizzas)
print('Pizza Total: $%0.2f '%pizza_total,end="")


def main():
get_pizza_info()

if __name__ == "__main__":
main()

===============================

-====================================Thank Yiou


Related Solutions

Write a Python function that takes a list of string as arguments. When the function is...
Write a Python function that takes a list of string as arguments. When the function is called it should ask the user to make a selection from the options listed in the given list. The it should get input from the user. Place " >" in front of user input. if the user doesn't input one of the given choices, then the program should repeatedly ask the user to pick from the list. Finally, the function should return the word...
Write a function called draw_card. It takes no arguments and returns an integer representing the value...
Write a function called draw_card. It takes no arguments and returns an integer representing the value of a blackjack card drawn from a deck. Get a random integer in the range 1 to 13, inclusive. If the integer is a 1, print "Ace is drawn" and return 1. If the integer is between 2 and 10, call it x, print "<x> is drawn" and return x (print the number, not the string literal "<x>"). If the number is 11, 12,...
Write a function named hasNValues which takes an array and an integer n as arguments. It...
Write a function named hasNValues which takes an array and an integer n as arguments. It returns true if all the elements of the array are one of n different values. If you are writing in Java or C#, the function signature is int hasNValues(int[ ] a, int n) If you are writing in C or C++, the function signature is int hasNValues(int a[ ], int n, int len) where len is the length of a Note that an array...
Write a Python function that accepts three arguments: an array, the size of the array, and...
Write a Python function that accepts three arguments: an array, the size of the array, and a number n. Assume that array contains integers. The function should display all integers in the array that are greater than the number n. Test your function.
Write functions in Python IDLE that do the following: i) A function that takes 2 arguments...
Write functions in Python IDLE that do the following: i) A function that takes 2 arguments and adds them. The result returned is the sum of the parameters. ii) A function that takes 2 arguments and returns the difference, iii) A function that calls both functions in i) and ii) and prints the product of the values returned by both.
Python: How would I write a function that takes a directory and a size in bytes,...
Python: How would I write a function that takes a directory and a size in bytes, and returns a list of files in the directory or below that are larger than the size. For example, I can use this function to look for files larger than 1 Meg below my Home directory.
(In python) 4. Write a function that involves two arguments, named changeTheCase(myFile, case), that takes, as...
(In python) 4. Write a function that involves two arguments, named changeTheCase(myFile, case), that takes, as arguments, the name of a file, myFile, and the case, which will either be “upper” or “lower”. If case is equal to “upper” the function will open the file, convert all characters on each line to upper case, write each line to a new file, named “upperCase.txt”, and return the string “Converted file to upper case.” If case is equal to “lower” the function...
PYTHON 3: Write a recursive function that takes a non-negative integer n as input and returns...
PYTHON 3: Write a recursive function that takes a non-negative integer n as input and returns the number of 1's in the binary representation of n. Use the fact that this is equal to the number of 1's in the representation of n//2 (integer division) plus 1 if n is odd. >>>numOnes(0) 0 >>>numOnes(1) 1 >>>numOnes(14) 3
I have a python coding question: Write the function: eAapproximately (n), that takes a positive integer...
I have a python coding question: Write the function: eAapproximately (n), that takes a positive integer value n and returns an approximation of e as (1 + 1/n)^n I am not even sure what the question is asking me to do but I think it is asking me to code that function. Does anyone know how to do this?
Write a function called fillList that takes three parameters, an integer array, input file, and size....
Write a function called fillList that takes three parameters, an integer array, input file, and size. The function should fill the integer array with randomly generated values between two numbers lowLim and highLim read from the input file. in C++
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT