Practise formatting floating point numbers
In the Python format method, a colon means 'format this data', a dot followed by a number tells Python how many decimal places you want to format a floating point number to and the letter f tells Python that the number is a floating point number. Study these examples, which all use the format method:
print("3.141592 is {}".format(3.141592)) results in 3.141592 being displayed.
print("3.141592 to one decimal place is {:.1f}".format(3.141592)) results in 3.1 being displayed.
print("3.141592 to two decimal places is {:.2f}".format(3.141592)) results in 3.14 being displayed.
print("3.141592 to two decimal places with a sign is {:+.2f}".format(+3.141592)) results in +3.14 being displayed.
print("-3.141592 to two decimal places with a sign is {:+.2f}".format(-3.141592)) results in -3.14 being displayed.
print("3.141592 with no decimal places is {:.0f}".format(3.141592)) results in 3 being displayed.
Q1. Display 5.673046 to 1 decimal place. Display the answer in a sentence, as in the above examples.
Q2. Display 5.673046 to 2 decimal places. Display the answer in a sentence, as in the above examples.
Q3. Display 5.673046 to 3 decimal places. Display the answer in a sentence, as in the above examples.
Q4. Display 5.673046 to 4 decimal places. Display the answer in a sentence, as in the above examples.
Q5. Display 5.673046 to 5 decimal places. Display the answer in a sentence, as in the above examples.
Q6. Display 5.673046 to 6 decimal places. Display the answer in a sentence, as in the above examples.
Q7. Display 5.673046 to 0 decimal places. Display the answer in a sentence, as in the above examples.
Q8. Display 5.673046 to 3 decimal places and with its sign. Display the answer in a sentence, as in the above examples.
Q9. Display -5.673046 to 2 decimal places and with its sign. Display the answer in a sentence, as in the above examples.
Q10. Select some numbers and write some formatting questions like the examples above. Challenge someone sitting next to you, to see if they can format the numbers in the way that you want.