This week we are introducing our newest module, Python with Code Warrior Dale Chase!
How to Install Python
Go to Python.org and click on Python 2.7.6 under "Download". Choose the installer package for your operating system and click on them. The file will be downloaded. It is important to download 2.7 because 3.4.0 is NOT compatible with our lessons. If you want more information on what the differences are between 3.x and 2.x, please check out this handy information.
- Note: Python is AUTOMATICALLY INCLUDED ON MacOS X ... however, you should probably download the latest rev2 version.
- Viewer submissions and questions will be back next week!
To see all the code used in today's episode, go to Our Github Repository for Module 2
Compiled vs. Interpreted Languages
- Compiled languages are reduced to a set of machine-specific instructions before being saved as a executable file
- Intepreted Languages are saved in the same format that you entered, then converted into machine language "Just in Time" - when they are needed.
- Compiled Languages generally run faster, but are a little trickier to develop since they much be compiled for each platform that may use the program
- Interpreted Languages generally run more slowly than Interpreted languages, but are more convienent for developers.
- In C#, you ended a line of code by typing ";"
- In Python, the WHITESPACE deliniated lines of code
- In C#, we had to explicitly declare variables to reserve memory space.
- INT (Integer) = 2 Bytes 65536
- LONG INT (Integer) = 4 Bytes 4,294,967,296
- CHAR (Character) = 1 Byte 256
- FLOAT (Floating Point) = 4 Bytes 4,294,967,296
- We had to tell C# EXACTLY what type of data would be going into the variable, and it would reserve the necessary space in memory.
- We don't have to do that in Python.
- Variables in Python are declared AUTOMATICALLY when a value is stored in the variable.
Here's how it works.
Var1 = 100 -- This becomes an INT
Var2 = "Hello World" -- This becomes an STRING
Var3 = "3.14" -- This becomes a FLOAT
Python has several Data Types:
- (int, long, float, complex)
- Contiguous Set of Characters
- Read-Only Lists
- A Hash Table
Output to Screen
print "Hello World"
Yo = "Hello World"
Input from user:
- Python has a built-in function called "raw_input()"
- When you use this function as follows:
var1 = raw_input("What's your age?")
Get in Touch With Us!
- Subscribe and get Coding 101 automatically at TWiT.tv!
- Follow PadreSJ and Snubs on Twitter
- Watch the show live and join the chatroom every Thursday at 1:30pm PST.
Download or subscribe to this show at twit.tv/code.
Bandwidth for Coding 101 is provided by CacheFly.