0

Any suggestions?

https://code.sololearn.com/cAWv7ZAzrisc/#py I'm trying to make a calculator that can handle tax and decimals. I have pretty much everything figured out. However, on the last line I can't seem to round it without breaking something. That being said, I don't really even need the final result (change) to be rounded. Is there a way to cut numbers off to where only 2 decimals are displayed?

16th Dec 2019, 3:30 PM
Joshua Cronin
Joshua Cronin - avatar
7 Answers
+ 1
print(f'... is the begin of a "simple" formated print statement for python. inside the {} stand the variable to print. And after the colon var:. 2f is the format. In this case: print variable var with 2 decimals as float. That's all 😉
16th Dec 2019, 5:18 PM
Coding Cat
Coding Cat - avatar
+ 1
This one displays 2 decimals rounded: https://code.sololearn.com/cTpIevROZt7J/?ref=app
16th Dec 2019, 4:53 PM
Coding Cat
Coding Cat - avatar
+ 1
Imma have to write down that answer cause brain had an error. But for some reason having a -.01 corrects some kind of rounding issue. Idk why. But tyvm for the advice!
16th Dec 2019, 5:21 PM
Joshua Cronin
Joshua Cronin - avatar
0
Awwww You mean I could have just typed that? xD In my defense I have no idea what that is suppose to do. Im still at object orientated programming in python stuff here. What exactly is f? and why the {}?
16th Dec 2019, 4:56 PM
Joshua Cronin
Joshua Cronin - avatar
0
Is not clear? Here is your code with change in line 44 But I'm not sure, if you need the +0.01 https://code.sololearn.com/csXaE7nrB5C0/?ref=app
16th Dec 2019, 5:05 PM
Coding Cat
Coding Cat - avatar
0
I can see what you did. But why the {}. And im unsure what f' is suppose to do. Im not trying to be difficult.
16th Dec 2019, 5:08 PM
Joshua Cronin
Joshua Cronin - avatar
0
You're welcome
16th Dec 2019, 5:23 PM
Coding Cat
Coding Cat - avatar