# OLD: Parts of Python (old -- Mr. A)

## Expectations <a href="#expectations" id="expectations"></a>

We're going to take a tour of Python. You are expected to know generally _what_ these things are, you're not yet expected to know _how_ to use them. So no freaking out. We'll play around with some fun projects after a quick look around.

### Learning Targets <a href="#learning-targets" id="learning-targets"></a>

* I can make a hello world app in Python.
* I can differentiate between compile-time, run-time, and logic errors.
* I can describe the basic constructs of programming languages such as variables, conditionals, loops, and flow control.

### Assessments <a href="#assessments" id="assessments"></a>

* You will be answering comprehension questions about the layers supporting software execution.
* You will be creating and submitting your first Python app using trinket.io

Let's go to trinket.io and build some simple stuff, starting with `print("Hello, world")`

We'll go over each of these concepts in greater detail. For now, let's skim over all the big topics.

## Data Types

The first thing we'll tinker with is **declaring** variables and storing information. Variables in Python are **dynamically typed**, meaning you can store one type of information in a variable and then switch it without any fuss. Other languages are more strict and don't allow such shenanigans.&#x20;

![](https://1916862645-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LHmXRQJbjMi37frjOn8%2F-LKwJ-YdMjm3HGNEBRiI%2F-LKwQMm38Zu3WI3-_ii1%2Fimage.png?alt=media\&token=9456b3ad-4e53-4f13-87f4-5b843f0d6f71)

## Operations

{% embed url="https://www.loom.com/share/7221399afc924044a959c978c98cd0c2" %}

We use math symbols for most common operations. But Python has some cool operators. Read!

{% embed url="https://www.tutorialspoint.com/python/python_basic_operators.htm" %}

![Yeah, reading. Push yourself to skim tech guides so you know what's availabe.](https://1916862645-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LHmXRQJbjMi37frjOn8%2F-Lmdj3X18D2iuz4JUBD4%2F-LmdqY_Symzy3kQBfH1i%2Fgiphy%20\(1\).gif?alt=media\&token=cb4afeaa-ef92-471a-a8ac-910d5fe64416)

## Conditionals

{% embed url="https://www.loom.com/share/f3fe6e11cf2747df976bd2dc9abb09c7" %}

Now we're switching from declarations and operations to control flow. Now we can direct the computer's train of thought (aka its **thread**).&#x20;

![](https://1916862645-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LHmXRQJbjMi37frjOn8%2F-LKwJ-YdMjm3HGNEBRiI%2F-LKwQ8RrEwuKmvPxe-4d%2Fimage.png?alt=media\&token=58bbaeca-4c1b-4781-94af-84a8188a0cbf)

![](https://1916862645-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LHmXRQJbjMi37frjOn8%2F-LKwJ-YdMjm3HGNEBRiI%2F-LKwQEAsIh9YrHtYH4JV%2Fimage.png?alt=media\&token=7e3a3702-d0d1-4d5a-9eb2-f341e3370788)

![](https://1916862645-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LHmXRQJbjMi37frjOn8%2F-LKwJ-YdMjm3HGNEBRiI%2F-LKwQGk6hAqc8GCD_v71%2Fimage.png?alt=media\&token=6eaa8544-01ed-407f-9421-c5607afe557f)

## Loops

{% embed url="https://www.loom.com/share/792db98c565545dcb7bf34f61d85016b" %}

This is how we repeat commands and **iterate** through a list or collection of items. Imagine you're using your hand to flip through posters at Walmart. Your hand selects each poster as it **traverses** the collection. That makes your hand the **iterator** as it is connecting with each object in the collection during the loop.&#x20;

![](https://1916862645-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LHmXRQJbjMi37frjOn8%2F-LKwJ-YdMjm3HGNEBRiI%2F-LKwQSvGZ-lqPTiwpYov%2Fimage.png?alt=media\&token=64268fb7-8f2a-4615-948a-627e6173eccc)

![x in this loop is the iterator as it's the variable that traverses the collection](https://1916862645-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LHmXRQJbjMi37frjOn8%2F-LKwJ-YdMjm3HGNEBRiI%2F-LKwQW3iEKug1cXk4hap%2Fimage.png?alt=media\&token=cb9661c0-5db1-492f-8b77-836d7efc2086)

![](https://1916862645-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LHmXRQJbjMi37frjOn8%2F-LKwJ-YdMjm3HGNEBRiI%2F-LKwQXvNCCd2cGycJveH%2Fimage.png?alt=media\&token=ae577005-d56c-423e-82d7-318c605853b9)

![](https://1916862645-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LHmXRQJbjMi37frjOn8%2F-LKwJ-YdMjm3HGNEBRiI%2F-LKwQ_LCv32EQCVhXLOV%2Fimage.png?alt=media\&token=6ea3e0a5-a618-42e9-a4c6-c042f5dfb797)

![](https://1916862645-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LHmXRQJbjMi37frjOn8%2F-LKwJ-YdMjm3HGNEBRiI%2F-LKwQbDHEfMfXRIku3kk%2Fimage.png?alt=media\&token=f9d827e0-8928-4692-a792-22635b26fcf4)

![](https://1916862645-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LHmXRQJbjMi37frjOn8%2F-LKwJ-YdMjm3HGNEBRiI%2F-LKwQd1QdWDIg_o9n-PC%2Fimage.png?alt=media\&token=067bfafe-de49-471d-9e1a-01c031fb3859)

## Functions/Methods

A function is a set of commands you can call. When activating this "magic spell" you can pass it parameters or ingredients.&#x20;

![the "return" keyword is a big one](https://1916862645-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LHmXRQJbjMi37frjOn8%2F-LKwJ-YdMjm3HGNEBRiI%2F-LKwQnpweBo40kn1kbwt%2Fimage.png?alt=media\&token=23d91666-9320-497e-9be2-87f3adc6cdda)

![](https://1916862645-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LHmXRQJbjMi37frjOn8%2F-LKwJ-YdMjm3HGNEBRiI%2F-LKwQqjHkCaz_uR6BfyN%2Fimage.png?alt=media\&token=f2e307a9-022e-44d7-8d94-ed06aac43d41)

![Whoa, combining concepts! ](https://1916862645-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LHmXRQJbjMi37frjOn8%2F-LKwJ-YdMjm3HGNEBRiI%2F-LKwQs1wfHr0u4OGF0y9%2Fimage.png?alt=media\&token=2259f719-7320-4da2-93da-a3b037d3e549)

![](https://1916862645-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LHmXRQJbjMi37frjOn8%2F-LKwJ-YdMjm3HGNEBRiI%2F-LKwRFeO27pV9akZdrv6%2Fimage.png?alt=media\&token=a99c23d6-91c2-41da-8bcb-804d40420e11)

## Classes

{% hint style="danger" %}
This concept is pretty advanced. It's here as a reference point because exposure to these ideas is good (so long as you know that it's not something you need to master quite yet).
{% endhint %}

A class is how you can create your own objects. You can make an class serve as a single worker like a static library of mathematical operations or you can design your own object, like a Spaceship that can be spawned or instantiated into a game many times. It'll have its own instance variables like health and shield properties.&#x20;

![](https://1916862645-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LHmXRQJbjMi37frjOn8%2F-LKwJ-YdMjm3HGNEBRiI%2F-LKwQx30SdQ3qobheIqF%2Fimage.png?alt=media\&token=5fa52180-11be-49c1-a1f7-06dc2ba4be8f)

![](https://1916862645-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LHmXRQJbjMi37frjOn8%2F-LKwJ-YdMjm3HGNEBRiI%2F-LKwQydmq9Mz0aIjsDjU%2Fimage.png?alt=media\&token=bccd8ec5-8d77-4c46-8937-6d570505ed44)

![](https://1916862645-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LHmXRQJbjMi37frjOn8%2F-LKwJ-YdMjm3HGNEBRiI%2F-LKwR-AaP9hkl3KVYo_8%2Fimage.png?alt=media\&token=5cf87b4e-df80-4c3e-9d1a-51459043d74c)

![](https://1916862645-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LHmXRQJbjMi37frjOn8%2F-LKwJ-YdMjm3HGNEBRiI%2F-LKwR0z_Oo6-5G97r5Ei%2Fimage.png?alt=media\&token=3c6e56af-d28c-4e0d-9d78-349169a32ea7)

![](https://1916862645-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LHmXRQJbjMi37frjOn8%2F-LKwJ-YdMjm3HGNEBRiI%2F-LKwR2BIszg-7pgLMfFi%2Fimage.png?alt=media\&token=29aa021d-6408-46d0-9905-12722702d6c0)

![](https://1916862645-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LHmXRQJbjMi37frjOn8%2F-LKwJ-YdMjm3HGNEBRiI%2F-LKwR4bNJUvp1z__TtY6%2Fimage.png?alt=media\&token=261fbe28-6875-4246-bb7a-1ec4065e7b35)

![](https://1916862645-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LHmXRQJbjMi37frjOn8%2F-LKwJ-YdMjm3HGNEBRiI%2F-LKwR9zwvk0ym9QFHzWy%2Fimage.png?alt=media\&token=5a305223-165a-48d9-8faa-9d54f1933092)
