3/19/26, 3:43 PM Introduction_to_Python
Open in Colab
Introduction to Programming with
Python
Options create a Colab Notebook:
Go to [Link]
Or in [Link]
Select "+ New" in top right hand corner
Select "More" and then "Google Colaboratory"
NOTE: For both options you must be logged in to Google
Adding and moving cells
Add new cells by using the + CODE and + TEXT buttons that show when you hover
between cells.
You can move a cell by selecting it and clicking Cell Up or Cell Down in the top toolbar.
Markdown Cell vs. Python Cell
Markdown Example
This is a markdown cell.
Python Example
In [2]: "This is a python cell"
Out[2]: 'This is a python cell'
How to Run a Cell
Easy Way: Click the run button.
Pro Way: With cell selected type Cmd/Ctrl+Enter.
Other Pro Tips:
Type Shift+Enter to run the cell and move selection to the next cell
Type Alt+Enter to run the cell and insert a new code cell below it
In [4]: 2 + 3
[Link] 1/5
3/19/26, 3:43 PM Introduction_to_Python
Out[4]: 5
Python Basics
Cells print out below it it's results.
In [3]: 1 + 1
Out[3]: 2
If you have multiple lines only the last line will show.
In [1]: 2 + 2
3 * 3
Out[1]: 9
The print() function outputs the specified message to the console, allowing you to
display text, variables, or the results of expressions.
Note: We'll cover functions (e.g., sum() , max() ) in an upcoming lesson, but
understand that this is one of many Python functions to perform common tasks.
In [2]: print("What's Up, Tech Crushers!")
print(2 + 2)
print(3 * 3)
What's Up, Tech Crushers!
4
9
Technically, I could remove that last print function.
In [6]: print("What's Up, Data Nerds")
print(2 + 2)
3 * 3
What's Up, Data Nerds
4
Out[6]: 9
Make a Comment
What if you wanted to include something in your code like a note?
Include a # before the line
This is called a comment
That doesn't execute anything and isn't read by the Python interpreter when executing
your code.
In [7]: # This is a comment. Nothing to the right of the "#" sign will be interpreted
[Link] 2/5
3/19/26, 3:43 PM Introduction_to_Python
In [8]: # This is a comment
print("What's Up, Data Nerds")
print(2 + 2) # This is a comment also
3 * 3
What's Up, Data Nerds
4
Out[8]: 9
Markdown Basics
Markdown is a lightweight markup language that uses characters like # for headings and
* for emphasis to format text simply and intuitively.
Element Markdown Syntax
# H1
Heading ## H2
### H3
Bold **bold text**
Italic *italicized text*
Blockquote > blockquote
1. First item
Ordered List 2. Second item
3. Third item
- First item
Unordered List - Second item
- Third item
Code `code`
Horizontal Rule ---
Link [title]([Link]
Image 
Here is a more info on Markdown
Python Terms
Terms to know:
Object
Variable
Function
Objects: The Data Records
[Link] 3/5
3/19/26, 3:43 PM Introduction_to_Python
In data science, an object is like a record in your spreadsheet. Each record can have
multiple fields, such as job title, location, and salary.
Object: A data record with fields.
In [7]: 1000000 # this is an object
Out[7]: 1000000
In [8]: "Data Scientist" # this is also an object
Out[8]: 'Data Scientist'
Python is object-oriented, so even the data types are objects.
In [9]: type("Data Scientist") # this shows that this is an instance of the class 'str'
Out[9]: str
Functions are also objects in Python.
In [17]: print()
In [11]: type(print)
Out[11]: builtin_function_or_method
Variables: The Reference to Objects
Think of a variable as a container. You can store data in it, like a number, text, or a
formula.
Variable: A defined name that references an object.
In [13]: job_title = "Data Scientist"
job_salary = 1000000
my_print_function = print
In [15]: print(job_title, job_salary)
Data Scientist 1000000
Variables that reference the same object are... the same.
In [18]: data_job = job_title
data_job
Out[18]: 'Data Scientist'
However, variables that may look the same, but reference different objects are... different.
[Link] 4/5
3/19/26, 3:43 PM Introduction_to_Python
In [ ]:
Functions: The Manipulators of Objects
Functions are like custom formulas in Excel. They perform tasks that can be applied to
different sets of data.
Function: A reusable piece of code that performs a specific task.
The print() we saw already is a function.
In [22]: # provide functions arguments to print in parenthesis
print("Good Evening, Data Scientists!")
Good Evening, Data Scientists!
I could make this into a function:
In [23]: def greet():
return "Good Evening, Data Scientists!"
In [24]: greet()
Out[24]: 'Good Evening, Data Scientists!'
[Link] 5/5