To Lecture Notes

IT 212 -- Sep 9, 2020

About IT 212

Course Website

Course Topics

  1. Review of Python from IT 211
  2. Binary and hex numbers
  3. Bitwise operations
  4. Reading from and writing to files
  5. Lists of lists
  6. Classes and objects
  7. Dictionaries
  8. Python and SQLite
  9. Regular Expressions
  10. Intro to Java

Review Quiz

  1. Give examples of Python constants of these datatypes:
    integer (int), floating point (float), string (str), boolean (bool). Ans:
     
    Meaning Datatype Example Constants
    Integer int 385  -47  0
    Double Precision
    Floating Point
    float 34.87  -8.67e15
    3.12e-27  0.0
    String str "boy"  'boy'
    Logical or Boolean bool True  False

  2. Suppose that we have the variable assignments
    name = 'Larry'
    amt = 235.41
    
    The output should look like this:
    Larry owes me $235.41.    (*)
    
    Format the values of name and amt so that the output looks like (*). Format the output in four ways: (a) listing the values, (b) concatenating the values, (c) expression interpolation using an f-string, (d) using the string format method. Ans:
    # (a) Listing the items.
    # sep="" is needed so there is no space between the fields.
    print(name, " owes me $", amt, ".", sep="")
    // or
    print(name, " owes me $" + str(amt) + ".")
    
    # (b) Concatenation.
    print(str(name) + " owes me $" + str(amt) + ".")
    
    # (c) Expression interpolation with F-string
    print(f"{name} owes me ${amt}.")
    
    # (d) String format method.
    print("{0:s} owes me ${1:6.2f}".format(name, amt))
    
  3. What are the rules for spelling a legal Python variable name?
    Ans: Must start with letter or underscore, and must consist of letters, digits, or underscores. A single underscore ( _ ) can actually be a Python variable name, but is not recommended.
    Instead of using underscores, Python variable names can use lower camel casing where the variable name starts with a lowercase letter each new word begins with an uppercase letter, for example: numCustomers.
    You should be consistant: either use underscore notation all the time for variable names, or use camel casing all the time.

Binary and Hex Numbers

Project 1