Question

Okay, so I am very new to programming. I've started teaching myself python-3.2, and am attempting to write a program which shows what any restaurant bill would be with a 15% tip and a 20% tip. I keep on getting:

Traceback (most recent call last):   
  File "/home/marian/restaurantbilltotal.py", line 6, in <module>     
    print(fifteen ("Plus a 15% tip: "))
TypeError: 'int' object is not callable tip

The code I have written is:

#Restaurant bill total

bill = int(input("Restaurant bill total: "))

fifteen = (bill // 100) * 15 + bill
print(fifteen ("Plus a 15% tip: "))

twenty = (bill // 100) * 20 + bill
print(twenty ("Plus a 20% tip: "))

input("\n\nPress the enter key to exit.")

Please help, but keep in mind I've only just started to learn how to programme :-). Thanks.

Was it helpful?

Solution 2

bill = int(input("Restaurant bill total: "))

fifteen = (bill * 0.15)

twenty = (bill * 0.20)

print("Your Actual bill : ", bill)
print("Bill with 15% additional charge : ", bill+fifteen)
print("Bill with 20% additional charge : ", bill+twenty)

input("\n\nPress the enter key to exit.")

OTHER TIPS

fifteen is an integer value. You are trying to treat is like a function by calling it:

print(fifteen ("Plus a 15% tip: "))

Perhaps you wanted to print it after the text:

print("Plus a 15% tip:", fifteen)

The same error applies to twenty, correct it in a similar fashion:

print("Plus a 20% tip:", twenty)

You should write:

print ('Plus 15% tip:' , str(fifteen))

In your code it's interpreted like: fiften('Plus 15% tip: ') just as it was a function.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top