Python Console Output
Display text (and spaces/numbers/symbols):
Arrange text (tab, new line):
- "\t" will tab "world" to the right
- "\n" will put the text following it onto a new line
Display calculated values:
- With calculations you don't use quotes, otherwise it will display the calculation numbers "12+34" rather than the answer
Display a value with 2 decimal places:
- You can display to another number of decimals places, just change the number after %.
Have content take up a fixed amount of space
- This will add padding after the number so that it takes up 20 spaces total
- This is useful if you have another value on the same line and want it to be a fixed distance from the left side
- Use this if you have multiple lines containing words/numbers of varying length that you want to line up in columns
Display content aligned to the right
- This will add padding before the number so that it takes up 12 spaces total
Challenge
Write a program that will display the following on a line (where the blank line should show the actual answer calculated by the program, <tab> is replaced by a real position tab, and the numbers are shown to the 3rd decimal):
<right aligned> name = Bob
<tab>345 divided by 78 equals ___.