This forum is now read-only. Please use our new forums! Go to forums
tip calculatior
I like to play around when I learn and code things my way so that it can give the same result as in the tutorial.
But I noticed a problem, when I code my way for the tip calculator in the activity of getting the total, the console says am wrong. And I don’t know why.
My Code :
meal = 44.50 tax = 0.0675 tip = 0.15
meal = meal + meal * tax
total = (meal*2) * tip
print(“%.2f” % total)
Code that is suggested :
meal = 44.50 tax = 0.0675 tip = 0.15
meal = meal + meal * tax
total = meal + meal * tip
print(“%.2f” % total)
So can some tell me why I would be getting an error because based on the math I know…both statements are pretty much the same.
Answer 53cfa50f282ae380b9001ab0
Popular free courses
- Free Course
Learn SQL
In this SQL course, you'll learn how to manage large datasets and analyze real data using the standard data management language.Beginner friendly,4 LessonsLanguage Fluency - Free Course
Learn JavaScript
Learn how to use JavaScript — a powerful and flexible programming language for adding website interactivity.Beginner friendly,11 LessonsLanguage Fluency - Free Course
Learn HTML
Start at the beginning by learning HTML basics — an important foundation for building and editing web pages.Beginner friendly,6 LessonsLanguage Fluency
3 comments
yes but the thing is multiplication and addition are commutative…so it doesn’t matter the order in which you work them….remember multiplication is repeated addition. So still don’t get why.
https://en.wikipedia.org/wiki/Order_of_operations
hmmmm…Thank you….I mixed around my math terms and thought wrong….I looked it over and your right thanks.