Предполагается, что калькулятор определяет для каждого гостя равную сумму для оплаты общего счета
Мой код:
Total_Bill_Value=int(input("Enter your total cost of the Bill : "))
#Requests user to input the value of their bill
Num_of_Guests=int(input("Enter the total number of Guests : "))
#Requests users to input number of guests
Calc_Tip=(Total_Bill_Value/100)*15
#Calculates 15% of the bill as tip
Total=Total_Bill_Value+Calc_Tip
#total of the bill including tip
Total_Tip=Calc_Tip/Num_of_Guests
#Splits the tip equaly among all guests
Total_Pay=Total/Num_of_Guests
#Splits the total bill equaly among all guests
def main ():
print("The Tip(15% of bill) is =${}".format(Calc_Tip))
print("The Total cost of bill including Tip is = ${}".format(Total))
print("Required amount from each Guest for the Tip is:")
for i in range(1,Num_of_Guests+1):
print("Guest{} =${:.2f}".format(i,Total_Tip))
print("Required amount from each Guest for the Total bill is:")
for i in range(1,Num_of_Guests+1):
print("Guest{} =${:.2f}".format(i,Total_Pay))
if __name__ == '__main__':
main()
Мне нужно создать тестовые случаи, но я не совсем уверен, как полностью делайте это каждый раз, когда я запускаю этот код, чтобы проверить, работает ли он или нет, он говорит, что тест не пройден, и он также требует от меня ввода значений также
Код TestCase:
import unittest
import BillCalc
class Test(unittest.TestCase):
def test2(self): #it checks the main method
self.assertEqual(3.75, BillCalc.Total_Tip(100,4))
if __name__ == '__main__':
unittest.main()