Page 216 -
P. 216

modular programming







                             Match each format string to what it does. We’ve already done one for you.




               "%s %e" % ("Value is", 16.0 ** 0.5)            Display a string followed by 4.000000.



               "%7d" % (11232/3)                              Display a string followed by 4.000000e+00.



               "%x" % 127                                     Display the value, padded with 0s.



               "%20s\n" % "Banana swirl"                      Display the result of the calculation, padded
                                                              with spaces.


               "%s is $%4.2f" % ("Popsicle", 1.754)           Pad the string out to 20 characters, then display a
                                                              newline character.


               "%s %f" % ("Value is", 16.0 ** 0.5)            Display the number as a hexidecimal (base 16).



               "%07d" % (11232/3)                             As well as a string, also display a floating point
                                                              number to 2 decimal places.








                                                Look back at the records you need to create for the transaction
                                                file. Each line will need to end with a newline character. If you
                         Be careful with the    have the credit card number, price, and description in variables
                         decimal point in the price.  called credit_card, price, and description, write
                                                down what you would use for the format string:










                                                                                      you are here 4    181
   211   212   213   214   215   216   217   218   219   220   221