Chapter 2
Chapter 2
Chapter 2
Enter the amount of sales for each day and press Enter.
>>> val = 10
>>> print(f'The value is {val + 2}.')
The value is 12.
.2f means:
round the value to 2 decimal places
display the value as a floating-point number
Field width = 12
Examples:
print(f'{num:<20.2f}')
print(f'{num:>20.2f}')
print(f'{num:^20.2f}’)
Ext2
Example:
print(f'{number:^10,.2f}')