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 function in python that takes in an integer n and computes the left hand...
Write a function in python that takes in an integer n and computes the left hand Riemann sum of the function f(x) = x^2 on the interval [0,1]. Hint: compute the error from the true answer
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.
python exercise: a. Write a function sumDigits that takes a positive integer value and returns the...
python exercise: a. Write a function sumDigits that takes a positive integer value and returns the total sum of the digits in the integers from 1 to that number inclusive. b. Write a program to input an integer n and call the above function in part a if n is positive, else give ‘Value must be Positive’ message. sample: Enter a positive integer: 1000000 The sum of the digits in the number from 1 to 1000000 is 27000001 Enter a...
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
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT