The program takes two float variables a and b as input and performs string formatting on their values. The values of a and b are assigned to 23.36778 and -74.99 respectively. The original values of a and b are printed first.
The next line formats the value of a by using the .format method on a string and specifies the format for the float value inside the curly braces {:.0f}. This format will remove all decimal places from the float value and round it down to the nearest integer. The formatted value is then concatenated with the string and printed. The same is done for the value of b in the following line. The output shows the original and formatted values of both a and b.
a =23.36778 b =-74.99 print("Original Value A : ", a) print("Formatted Value no decimal places A : "+"{:.0f}".format(a)); print("Original Value B : ", b) print("Formatted Value no decimal places B : "+"{:.0f}".format(b));
Original Value A : 23.36778 Formatted Value no decimal places A : 23 Original Value B : -74.99 Formatted Value no decimal places B : -75
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions