Question: Write a program named Formatting.py that does the following: Set up two variables (s1 and s2) to hold strings (This and That) and two more

 Write a program named Formatting.py that does the following: Set up

Write a program named Formatting.py that does the following: Set up two variables (s1 and s2) to hold strings ("This" and "That") and two more variables (il and i2) to hold integers (123 and -5). Then write appropriate print statements that use these variables and the format method to print the following to the console (the blue numbers on top indicate positioning): Create two more variables: d1 = 123.4 and d2 = 3.1315926535 On a new line, right-justify d1 and d2 within the field-width of 10 (no decimal accuracy)- note what happens. On a new line, right-justify d1 and d2 with no field-width and no decimal accuracy- note what happens. On a new line, left-justify d1 with a width of 15, decimal accuracy of 4 and d2 within the field-width of 15 using a decimal accuracy of 10)- note what happens. Continued on next page -- rightarrow Finally, on a new line, left-justify the variable holding the string This and the variable holding the integer 123. each one within the field-width of 2 - note what happens: Does it create an error because the field widths are smaller than the actual values? Does it execute but, chops off part of the output, i.e. only displays 2 characters from each? Is all the data displayed in spite of the small field width

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!