Confusing variable name. Is the tip an amount or percentage?
I assumed the former based on variable name, but a commenter
has corrected me.
Keep calculation and presentation logically separate. You don't
need to create a variable for the rounded amount. Just compute
the per person cost in the natural way. When you are ready to display
that value in a human-readable form, format it as needed.
# Get user input.
bill = float(input('Bill: '))
tip_pct = float(input('Tip percentage: '))
npeople = int(input('People: ')) # int() seems more appropriate.
# Calculation.
per_person = bill * (1 + tip_pct / 100.0) / npeople
# Presentation.
message = f'Per person: ${per_person:.2f}'
print(message)
Next step: start putting your code in functions. As you try to write
programs longer than a few lines, adopt a strict discipline of putting
all code in functions and never relying on global variables (constants
are fine). There are many reviews on this site emphasizing such points.
The logical divisions illustrated above (collecting input, performing
calculations, presenting results) will continue to be relevant
as you start using functions.
Another next step: validating and generalizing the collection of user input. Currently, you ask the user for 3 numbers, but people make mistakes.
There are many reviews on this site illustrating how to write a simple
function taking a message (eg, "Enter the bill") and returning
a validated value, with the opportunity to recover from user errors.
round
the sum as well as display it with two decimals:2f
though, you're kind of doing the same thing twice. \$\endgroup\$float
for money` mistake. \$\endgroup\$floor
to round down. If the sum offinal_per_person
adds up to less thantotal_cost
then report thatx
cents are outstanding, or distribute the missing cents randomly among the persons. \$\endgroup\$