Python Programming class for beginners 2021-11-11

First Published: .

Suggested optional pre-requisites to have before the class

  • Install Python 3 (3.8 recommended, any version from Python 3.6 is fine)
  • Install PyCharm Community Edition or Professional Edition (is free for 30 days only)

Suggested optional reading material

Examples of the class today have been upload here

Material from some other classes

On this class, recorded on the video (1h 48m)

Why there are different types of variables

  • Memory
    • All are 0 and 1’s
  • How big can be a variable (float, integer, string)
  • Operations performed, like +
  • MT Notation I use

The order in which the instructions are performed (top to bottom).

  • Declaring a variable
  • We can call thinks that were previously defined up (like functions)
  • Loops will send the execution pointer up
  • Operations with integer variables
    • Additions
  • Operations with Strings

Language syntax and tricks (write a Notebook with your own notes)

  • Pre-created solutions, like reverse an string with for
  • Open a file, read the contents by lines to string, split the strings to arrays by a separator, like tab or space, get what you want by position.
with open(s_filename) as file:
    for s_line in file:
        print(s_line)

# Show Exceptions

# Show hexadecimal of the text:

# cd /home/carles/Desktop/code/carles/python-classes/2021-11-11

# hexdump -c text.txt

# remove enters, spaces at the end of the file with s_line.rstrip()

The blocks and functions

  • Indentation
  • Typical error missing :
  • Functions are for reusing code and reducing errors
    • As they are for reusing, they are flexible (parameters)

The while loop

  • The condition True
  • The condition in a variable
  • The condition in a if
  • Break
  • Pattern counter inside a loop

Building a Menu for user selection in text mode

  • Input
  • Validation

Questions

  • As part of the questions, a question about the mental process to Build the solution was raised.
    • TODO: Was explained
    • The importance of keeping Notes with snippets of code that you normally use one time and another
    • How to search in Google to find explanations in Python sites
  • A question was raised about how menus could be implemented using OOP
    • A parent Menu class, with a MenuAdmin class inheriting was demonstrated. The MenuAdmin inherits the menu options from the parent Menu, and adds Admin only options.
Views: 4,456 views

Rules for writing a Comment


  1. Comments are moderated
  2. I don't publish Spam
  3. Comments with a fake email are not published
  4. Disrespectful comments are not published, even if they have a valid point
  5. Please try to read all the article before asking, as in many cases questions are already responded

Leave a Reply