0
I can't solve this at all.
My assignment is to "Write a program that will multiply the sum of 5 and 6 by 57.3 and output the result" and I have "print(5+6*57.3)" Is there anything wrong? Also, the quotes I put in the beginning and end of the print statement are not actually there. Just to show what I have.
1 Answer
+ 2
Hi Dawson!
You have to use quotes to define a string and they don't need when you're using integers.
>>>"2" -> string
>>> 2 -> integer.
In Python, arithmetic operations are done using integers.
Another thing that you need to consider in arithmetic operations is operator precedence. It's something called "PEMDAS" in python(BODMAS in Mathematics). According to that, 1+2*3 returns 7 instead of 9. The reason that it returns 7 is because * operator has higher precedence than +. But, you can use parenthesis to handle this case since it has higher precedence than other operators. Hence, (1+2)*3 returns 9.
Your question says that multiply the sum of 5 and 6 by 57.3 meaning, you have to get the sum of 5 and 6 before multiplying them by 57.3.