Quiz #3 for October 8, 2020

Please use your Python system (IDLE or something else) to compute the following. Be prepared to show your work!

  1. Here are a set of numbers:

    122 74 95 188 174 17 43 8 70 114 117 37

    Please write a program to print them in a table with 3 rows and 4 columns, and line the numbers in each column up by the ones digit.

    Answer: Here is one such program:

    
    print("%3d %3d %3d %3d" % (122, 74, 95, 188))
    print("%3d %3d %3d %3d" % (174, 17, 43, 8))
    print("%3d %3d %3d %3d" % (70, 114, 117, 37))
    

    There are many other variations. In all cases, the output should be:

    
    122  74  95 188
    174  17  43   8
     70 114 117  37
    


UC Davis sigil
Matt Bishop
Office: 2209 Watershed Sciences
Phone: +1 (530) 752-8060
Email: mabishop@ucdavis.edu
MHI 289I, Programming for Health Informatics
Version of October 12, 2020 at 10:51PM

You can also obtain a PDF version of this.

Valid HTML 4.01 Transitional Built with BBEdit Built on a Macintosh