print upto 1 decimal place python

```print("{:.1f}".format(number)) # Python3
print "%.1f" % number          # Python2```

Here is what the above code is Doing:
1. It’s converting the number to a string.
2. It’s using the string’s format method to format the string.
3. It’s printing the string.

The string’s format method takes a format string as its first argument.
The format string contains a placeholder for the number.
The placeholder is a percent sign (%) followed by a number.
The number corresponds to the position of the value in the format string.
The first value is number 1, the second is number 2, and so on.

The placeholder can also include a format specifier.
A format specifier is a set of characters that specifies how the value should be formatted.
The most common format specifier is a period (.) followed by a number.
The number specifies the number of decimal places.

So, the placeholder %.1f in the format string means, “Put the first value here and format it with one decimal place.”

The string’s format method returns a new string with the values inserted into the placeholders.
The print statement prints the new string.

Note: The string’s format method is new in Python 3.
In Python 2, you can use the % operator on strings to accomplish the same thing.

Here’s an example of using the % operator:

number = 3.14159
print “%.2f” % number

The output is:

3.14

The % operator works like this:
1. It takes two arguments. The first is a format string. The second is a value.
2. It replaces the % in the format string with the string representation of the value.
3. It returns the new string.

The print statement prints the new string.

Note: The % operator is still supported in Python 3, but it’s considered outdated.
You should use the string’s format method instead.

Instructions
1.
Use the string’s format method to print the following floating-point numbers to one decimal place:

3.14159
12.345
89.3212

2.
Use the % operator to print the same numbers to one decimal place.

3.
Use the string’s format method to print the following floating-point numbers to two decimal places:

3.14159
12.345
89.3212

4