Gaddis Python 6e Chapter 02
Gaddis Python 6e Chapter 02
Input,
Processing,
and Output
print('Programming')
print('is')
print('fun!')
Program Output
Programming
is
fun!
Enter the amount of sales for each day and press Enter.
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
• Other examples:
• Other examples:
Field width = 12
• Examples:
• print(f'{num:<20.2f}')
• print(f'{num:>20.2f}')
• print(f'{num:^20.2f}')
[alignment][width][,][.precision][type]
• Example:
• print(f'{number:^10,.2f}')
INTEREST_RATE = 0.069
import turtle
• When the turtle's pen is up, the turtle does not draw
as it moves.