Skip to main content

Basics and Setup

Learning Goals

Preparation for class:

  1. Read over this webpage. All the links for the rest of the steps are on this page.
  2. Learn Computing Basics: Read Gaddis chapter 1 (pdf download)
  3. Practice some Python Arithmetic and Expressions on Google Colab (Google Colab)
  4. Download Python Crash Course to your computer
  5. Skim over Chapter 1 Python Crash course. Don't use this dated edition for install. We will install Python next week.
  6. Read Chapter 2 Python Crash Course, Variables and Simple Data Types
  7. Check out Trinket.io
  8. We will set up Python and Git and Github.

Introduction: Gaddis text Chapter 1

The Tony Gaddis Text, Starting with Python, has a good introductory chapter on Computers and Programming. A free pdf is available; Download here or click the image below to download it. Read it over before our first session. Perhaps you will find the binary number section overwhelming. There are better ways to approach this subject, so don't get caught in a loop and get overwhelmed if it is confusing.Focus on the other material. I will present binary numbers in a more intuitive process in our first session.

Gaddis Chapter 1 Computing fundamentals are a separate topic from Python Fundamentals. Notice these topics in Chapter 1 of the Gaddis text are not specific to Python:

1.1 | Introduction
1.2 | Hardware and Software
1.3 | How Computers Store Data
1.4 | How a Program Works

Only topic 1.5 mentions Python in the limited context of it being an interpreted language (as opposed to being a compiled language). Topic 1.5 also covers Python running in script mode and interactive mode, but we will wait until next class to experiment with these modes because we will need to install Python on your computers first.

1.5 | Using Python

We can begin learning Python in this first session without having to install Python because we will be working with Google Colab, which has a built-in Python Interpreter that will work in a web browser.

Think Python: Programming as a Way of Thinking

Jupyter Notebook on Google CoLab

Since no Python installation is required we will jump right into learning Python! It is a better flow for a first class that meets weekly.

So look over this first chapter before class and interact with the Python code as you work through Chapter 1.

Think Python Chapter 1

Basics: Think Python vs. Crash Course Python

The strength of Think Python is that the big picture goal is getting you think like a computer scientist by reducing the need to work with a code editor. That is why Think Python introduces functions much sooner that Python Crash Course or any other book that I have evaluated. Functions are the heart of any programming language. I think it is better to get familiar with them sooner than later.

The strength of Python Crash Course is that it gives you simple examples to actually code in a code editor, which is the weakness or Think Python. Regardless of the order, we need to carefully cover all of these fundamentals in the first 6 sessions. Coding assignments will ask you to create a program that includes every thing we cover in the first 6 sessions.

The terms for the fundamentals are different in any book, but the concepts and code is the same. So see the following chart for reference:

Python Fundamental Concepts and Keywords

We will cover all of these concepts in the first module, Programming Fundamentals so we will briefly touch on them in our first class:

Fundamental ConceptCode Keyword
Variablesmy_var = 'age'
Data Typesint, float, str, bool, list, tuple, set, dict
Control Flow: Decision Structures (if statements)if, elif, else
Control Flow: Repetition Structures (loops)for, while, break, continue
Functionsdef, return
User Inputinput(), int(), float(), str()

Comparison of Think Python vs. Python Crash Course

orderThink PythonPython Crash Course
1Programming as a Way of Thinking 30 + 12 type(42.0) str int 85 // 2Getting started print()
2Variables and StatementsVariables and Simple Data Types .title() .upper() .lower() "my_var = age" "string" "f{}{}" 123 1.5 my_const = 'CONST' comments \n \t
3Functions defIntroducing Lists [] .sort() .pop() .reverse()
4Functions and InterfacesWorking with Lists for in
5Conditionals and recursion if boolif statements if else elif
6Return Values def if else returnDictionaries {}
7Iteration and Search def for print() openUser Input and While loops
8Strings and Regular ExpressionsFunctions

Code Samples

Take a look at some of these code samples here.

Checkout Trinket.io

I have a trinket account and use it for embedding code samples in my slide presentations.

I did not discover trinket.io until after mid-term last semester, so I did not use them in the basics section.

Although, the Think Python online notebook is great for learning concepts, it really does not go into any detail on coding with a code editor. This is where I will diverge from Think Python. We need to be able to create multi-file projects in an Integrated Development Environment.

Therefore, we are all going to install Python and get it running on our laptops.

We have waited until now because this process is fraught with complications because there are so many options for setting up Python. It is highly disruptive for making a good start in a class that only meets once a week.

Some students may have already installed Python, but it is not set up correctly and will need to be reinstalled. Some students will have used Python in another class and they will be okay using it as is. Some Mac Students may need to download and install Xcode It can be a bit chaotic as each student comes on board with a successful setup. As much as possible, take this time to get to know your classmates and try to help each other.

You will also need to make sure you have Git installed on your computer. We will be learning Git on the command line and from within Visual Studio Code, but the easiest way to make sure you have Git installed on your system is to download Git Desktop, even though we will not use be using Git Desktop.

How to Install Git on Mac

Option 1: GitHub Desktop

Git is installed automatically. You can download GitHub Desktop here. Now, follow these steps:

  1. Click the link above and choose Download for macOS.
  2. When GitHub Desktop has downloaded, it should unzip itself automatically. If not, double-click it to unzip it.
  3. Drag the GitHub Desktop file to your Applications folder.

Option 2: Xcode

  1. Install Xcode from the App Store.
  2. Once Xcode has installed, open Terminal from Applications > Utilities.
  3. Type xcode-select --install and press Return.
  4. That command installs Command Line tools and, with them, Git.
  5. To check Git is installed properly, when Command Line has installed, type git --version and press Return.

How to Install Git on Windows

Go here and download git for Windows.

Python

Setting up your computer to work with a programming language is also known as "setting up your environment."

Installing Python from Python.org

There are multiple options for installing Python on both Macintosh and Windows operating systems. INLS 560-004 students are encouraged to use the download option at python.org.

We will confirm whether or not you have Python 3 installed. If not, we will visit Python.org and download and install, or upgrade your version of Python 3. This link will work for both Windows or Mac Users.

python screen shot link

Installing a Python IDE

The most popular IDE for editing Python files is Visual Studio Code.

I have read through multiple books and watched multiple online courses, and up-to-date sources (2023) uniformly use Visual Studio Code.

You can get it here for either Windows or Mac. After you download it, we will need to install the Python plugin files. I will also demonstrate PyCharm. I really like PyCharm but it is not open-source and it seems to run out of memory and then require memory setting changes. Therefore, I have decided to use Visual Studio Code. It would not hurt to download both and give each a try.

visual studio code link

Jupyter Notebooks

We will be learning via Jupyter notebooks via the Think Python materials on Google Colab, but we will not be using Jupyter Notebooks for assignments. Do not submit Jupyter notebook files for INLS 560 assignments.