100 Days of Python: Days 6 – 10

Day 6

  • Discussed functions, including built-in functions and user-defined functions.
  • Reviewed Indentation.  Python guidelines recommend using spaces, but the point is somewhat moot considering IDEs can be set to interpret tabs as the correct number of spaces.
  • Reviewed While loops.
  • Generally, For loops are for when you need to do something to each thing that you’re iterating over.  For loops are also good for looping through something a pre-determined number of times.  While loops are for when the number of iterations are irrelevant.  They will be run until a condition is met.
  • While loops are “more dangerous.”  Printing the condition result can help debug Infinite Loops.
  • Apps Created:
    • Played https://reeborg.ca/ to use functions to define game character movements.  Completed several scenarios so that the game character could adapt to various map environments.  There was an “escape the maze” scenario that was particularly difficult.  NEED TO REVISIT AFTER DAY 15 FOR ADVANCED “DEBUGGING EDGE CASES” CHALLENGE
Reeborg was great practice for building irrational anger towards my own code.

Day 7

  • Main point of the day’s lesson was to use learned skills to build Hangman game.
  • Learned for and while loops interpret strings as lists of letters
  • Apps Created:
    • Hangman
Completing the hangman app was gratifying. Playing it alone was near existential crisis-inducing.

Day 8

  • Reviewed functions further.  Discussed using parameters and arguments.
  • Reviewed positional arguments vs. keyword arguments
  • Apps Created:
    • Created personal letters with interchangeable names / locations.
    • Calculate cans of paint required for job.
    • Prime number checker
    • Caeser Cypher (encrypt and decrypt messages with an alphabetic shift)
      • Used while loop to run the program for as long as the user wished.
      • Used conditional statements to leave special characters alone
      • Used modulo to deal with very large alphabet shifts
The Caeser Cipher was a very cool project. I look forward to revisiting cryptography again in the future.

Day 9

  • Discussed dictionaries, keys and values.
  • Reviewed looping through dictionaries, calling values using keys.
  • Nested lists in dictionaries, dictionaries in dictionaries and dictionaries in lists.
  • Apps Created:
    • Student Grades App – Move library of students / score into a new library of students / grades.
    • Travel Log – Appended libraries of travel log entries to a list of libraries.
    • Silent Auction – Accepted names / bid amounts from bidders, determined who the winner was and announced the winner.  Used library to submit bids to a bid list.  Used separate functions to collect bids and determine the winner.
In the off chance an auction is held in my home, I’ll be ready.

Day 10

  • Reviewed functions with output
  • Learned to use ‘return’ as method of retrieving output from a function and utilizing it in the main code logic.
  • Learned that returns end the interpretation of code in a function and subsequent code added to the function will be completely ignored.
  • Reviewed Docstrings, which will appear in the intellisense window to explain important details of a function.
  • Apps Created:
    • Days in month calculator – name any month / year to determine how many days were in that month (including leap years).
    • Calculator – Created mathematical functions and stored them in a library.  Used recursive function to allow subsequent calculations beyond the first.
The calculator was a great exercise in writing efficient code. Seeing practical uses of libraries was something I had never picked up before in my previous coding experiences.
Tagged in:,


Leave a Reply

Your email address will not be published. Required fields are marked *