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 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 functions that do the following in Python: i) A function that takes 2 arguments and...
Write functions that do the following in Python: 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 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.
In Python, write a function called user_name that takes two arguments, first_name and last_name and creates...
In Python, write a function called user_name that takes two arguments, first_name and last_name and creates a “user name” consisting of the first three letters of the first name concatenated with the first three letters of the last name.   You can assume ach name is at least three letters long. Return the new user name.    your results should yield something like these test cases. >>> print(user_name("bob", "taft")) bobtaf >>> >>> print(user_name("Ralph", "Waldo")) RalWal >>>
Make a python code. Write a function named max that accepts two integer values as arguments...
Make a python code. Write a function named max that accepts two integer values as arguments and returns the value that is the greater of the two. For example, if 7 and 12 are passed as arguments to the function, the function should return 12. Use the function in a program that prompts the user to enter two integer values. The program should display the value that is the greater of the two. Write the program as a loop that...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT