Opportunity Through Data Textbook
  • Opportunity Through Data Textbook
  • Introduction
    • What is Data Science?
    • Introduction to Data Science: Exploratory Musical Analysis
  • Module 1
    • Introduction to Programming
      • The Command Line
      • Installing Programs
      • Python and the Command Line
      • Jupyter Notebook
    • Introduction to Python
      • Building Blocks of Python - Data Types and Variables
      • Functions
      • Formatting and Syntax
    • Math Review
      • Variables and Functions
      • Intro to Graphs
  • Module 2
    • Data Structures
      • Lists
      • Dictionaries
      • Tables
    • Programming Logic
      • Loops
      • Logical Operators
      • Conditionality
  • Module 3
    • Introduction to Probability
      • Probability and Sampling
    • Introduction to Statistics
      • Mean & Variance
      • Causality & Randomness
  • Module 4
    • Packages
    • Intro to NumPy
      • NumPy (continued)
  • Module 5
    • Introduction to Pandas
      • Introduction to Dataframes
      • Groupby and Join
    • Working with Data
    • Data Visualization
      • Matplotlib
      • Introduction to Data Visualization
  • Appendix
    • Table Utilities
    • Area of More Complicated Shapes
    • Introduction to Counting
    • Slope and Distance
    • Short Circuiting
    • Linear Regression
    • Glossary
  • Extension: Classification
    • Classification
    • Test Sets and Training Sets
    • Nearest Neighbors
  • Extension: Introduction to SQL
    • Introduction to SQL
    • Table Operations
      • Tables and Queries
      • Joins
  • Extension: Central Limit Theorem
    • Overview
    • Probability Distributions
      • Bernoulli Distribution
      • Uniform Distribution (Discrete)
      • Random Variables, Expectation, Variance
      • Discrete and Continuous Distributions
      • Uniform Distribution (Continuous)
      • Normal Distribution
    • Central Limit Theorem in Action
    • Confidence Intervals
  • Extension: Object-Oriented Programming
    • Object-Oriented Programming
      • Classes
      • Instantiation
      • Dot Notation
      • Mutability
  • Extension: Introduction to Excel
    • Introduction to Excel
      • Terminology and Interface
      • Getting Started with Analysis and Charts
      • Basics of Manipulating Data
    • Additional Features in Excel
      • Macros
      • The Data Tab
      • Pivot Tables
Powered by GitBook
On this page

Was this helpful?

  1. Module 1

Introduction to Python

What can Python do?

PreviousJupyter NotebookNextBuilding Blocks of Python - Data Types and Variables

Last updated 4 years ago

Was this helpful?

Coding or programming is the process in which we give certain instructions to our computer so that it can perform a task, such as calculating something.

A programming language is a language that we can use to tell the computer what to do. Just like every other language, it has rules of its own about how to write code. It gives us the guidelines for the layout of words and symbols for any task we might want the computer to do. You can think of it as any language such as English, Spanish, or Chinese. It tells us what format, structure, and syntax we have to use so that the computer will do what we want it to do.

Python is one of the many programming languages that exist, and is the main programming language we will use during this course. It is a general-purpose programming language that is not only used in data analysis and visualization, but also to develop web apps.

We will be using Python as a tool to process and analyze data. To get started, let's discuss the basics of Python's format.

In the last section, we showed the command line, and how the computer is waiting for you to tell it what to do. When the computer is ready for you to type, it will display three arrows that look like this: >>> . You will not need to type these arrows, they will appear automatically. Here is a picture of what they will look like in the command line.

These arrows show up when the computer is ready for you to type something. If there are no arrows, then the computer is working on what you last wanted it to do.

However, when we use the Jupyter Notebooks, these arrows will be invisible. Instead, the command line will look like this:

In our examples, we will type the arrows, but they are not necessary in Jupyter.

Before we start, any code, let's see what happens when we input information into the command line:

>>> 2
2

>>> 4000000
4000000

In the example above, Python takes the input after the prompt >>> , evaluates it, and displays whatever the input evaluates to in the next line. We will get to more complicated examples as we continue. For now, know that Python takes in an input where there is a prompt >>> and displays the output in the next line.

Glossary

Syntax in a language is a set of rules that tell us how we can correctly combine words or symbols in order for the computer to understand what we want it to do.

Input is the information we give our computer so that it can do the task we asked it to do.

Output is the result of the task that the computer will give back to us once it is finished.