What is Float Function:- If the argument is a string, it should contain a decimal number, optionally preceded by a sign, and optionally embedded in whitespace. The optional sign may be '+'
or '-'
; a '+'
sign has no effect on the value produced. The argument may also be a string representing a NaN (not-a-number), or a positive or negative infinity. More precisely, the input must conform to the following grammar after leading and trailing whitespace characters are removed:
Here floatnumber
is the form of a Python floating-point literal, described in Floating point literals. Case is not significant, so, for example, “inf”, “Inf”, “INFINITY” and “iNfINity” are all acceptable spellings for positive infinity.
So, Now we show a real life example with floating number and make a progrom like contribution money calculator between friends.
Example:-
print("welcome to the Contrilator.") # Contributon + calculator = Contrilator ? bill = input("What Was the Total Restro+Bar bill? ₹ ") tip = input("what percentage tip would you like to give ?type '0'for nothing: ") split = input("how many people to split the bill ? ") result = (float(bill) * float(tip) / 100) result2 = float(result) + float(bill) result3 = float(result2) / int(split) print(f"Each Person Should Pay: ₹ {round(result3,2)}")

OUTPUT – 2
OUTPUT – 3
OUTPUT – 4
Thank You ! ❤️