Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 0 additions & 69 deletions Day_1/00_Intro.md

This file was deleted.

45 changes: 0 additions & 45 deletions Day_1/madlib.py

This file was deleted.

75 changes: 75 additions & 0 deletions lessons/Part1/00_Introduction.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# Python Basics: Introduction

This unit provides a basic introduction to Python. By the end of the series, you should be able to:

1. Run Python from the Anaconda Navigator in a Jupyter Notebook.
2. Write basic commands using Python syntax.
3. Grasp the major Python [object](https://github.com/dlab-berkeley/python-intensive/blob/master/Glossary.md#object) [types](https://github.com/dlab-berkeley/python-intensive/blob/master/Glossary.md#type), including [integers](https://github.com/dlab-berkeley/python-intensive/blob/master/Glossary.md#integer), [floats](https://github.com/dlab-berkeley/python-intensive/blob/master/Glossary.md#floating-point-number), [strings](https://github.com/dlab-berkeley/python-intensive/blob/master/Glossary.md#string), lists, sets, and dictionaries
4. Operate and manipulate those objects.
5. Control the flow of your programs using [conditionals](https://github.com/dlab-berkeley/python-intensive/blob/master/Glossary.md#conditional-statement).

# What is Programming?

> ## Learning Objectives
>
> * Explain the difference between knowing a programming language and knowing how to program.
> * Explain how programming languages can differ.
> * Give useful debugging tips.
> * Offer helpful resource websites.
> * Explain how to Google an error.

## What it means to "know how to program"

Most programmers can program in more than one language. That's because they know *how to program* generally, as opposed to "knowing" Python, R, Ruby, or any other language.

In other words, programming is an extendible skill. Basic programming concepts - conditionals, for loops, functions - can be found in almost any programming language.

That being said, programming languages differ from one another in the following ways:

1. **Syntax**: The precise rules of how to structure code in a language. For example, whether to add a semicolon at the end of each line.
2. **Usage**: Different programming languages are designed for different goals. For example, JavaScript is generally for building websites, R is primarily a statistical programming language, Python is a general purpose programming lanaguage, etc.
3. **Level**: How close you are to the hardware. Any programming code ultimately ends up as machine code. The difference between languages lies in how they are represented to the user. For example, C is often considered lower level language than others, because certain concepts - such as memory management - are not abstracted away in C.
4. **Object-oriented:** Many programming languages are object-oriented in that they provide functionality to create objects, which allow the user to organize code and functions in useful modules.
5. **Many more**: Here's a [list](https://en.wikipedia.org/wiki/List_of_programming_languages_by_type) of all the types of programming languages out there.

So what should your first programming language be? That is, what programming language should you use to learn *how to program*? At the end of the day, the answer depends on what you want to get out of programming. Many people recommend Python because its fun, easy, and multi-purpose. Here's an [article](http://lifehacker.com/which-programming-language-should-i-learn-first-1477153665) that can offer more advice.

Regardless of what you choose, you will probably grow "comfortable" in one language while learning the basic concepts and skills that allow you to "hack" your way into other languages.

Thus "knowing how to program" means learning how to *think* like a programmer, not necessarily knowing all the language-specific commands off the top of your head. **Don't learn specific programming languages; learn how to program.**

## What programming is like

![xkcd](http://sslimgs.xkcd.com/comics/wisdom_of_the_ancients.png)

Here's the sad reality: When you're programming, 80% or more of your time will be spent debugging, looking stuff up (like program-specific syntax, [documentation](https://github.com/dlab-berkeley/python-intensive/blob/master/Glossary.md#documentation) for packages, useful functions, etc.), or testing. This does not just apply to beginner or intermediate programmers, although you will grow more "fluent" over time.

If you're a good programmer, you're a good detective!

## Debugging

Here's a useful mental workflow to keep in mind when you want to try and debug an error:

1. Read the errors!
2. Read the documentation.
3. Make it smaller.
4. Figure out what changed.
5. Check your syntax.
6. Print statements are your friend.
7. Even better than print statements - built-in debuggers! These are more advanced, but worth learning how to use when you're ready.

## Googling Errors

Here are some tips on how to use Google to resolve errors you run might into:

* Enter in Google the name of the computer language and the text in error message.
* Be sure to remove user- and data-specific information first!
* See if you can find examples that do and don’t produce the error.

## Stack Overflow Example

Often when you Google something, the most relevant and helpful result will be someone asking a similar question on StackOverflow. Just to give you an example of what this looks like, [this](https://stackoverflow.com/questions/1228299/change-one-character-in-a-string) is one of the top results if you Google "python change one character in a string". When we talk about strings and lists, you'll see why this might be a question you have!

StackOverflow is a great resource by which people can ask and answer questions. In the above case, there's a lot of different answers to the question -- some more detailed than others -- and you can go with the approach that works best for you.

Don't reinvent the wheel -- learning how to find the answer to the issues you run into is a critical part of becoming a capable programmer!
Original file line number Diff line number Diff line change
@@ -1,26 +1,25 @@
# Python Basics: 1 Running Python
# Python Basics: Running Python

> ## Questions
> How can I run Python programs?
>
> ## Learning Objectives
>
> * Running Python in Anaconda IDE
> * Running Python in IDEs
> * Jupyter Notebooks
> * Download the training material
> * Open Jupyter Notebook


## Running Python in Anaconda IDE
## Running Python in Integrated Development Environments

It's common to write python programs using either a text editor or an interactive/integrated development environment (IDE). An IDE is a software application that provides comprehensive facilities to computer programmers for software development. An IDE normally consists of a source code editor, build automation tools, and a debugger. Some of them come with package managers and other features, too.

There are many Python IDE's. You can see a comparison [here](https://en.wikipedia.org/wiki/Comparison_of_integrated_development_environments#Python)
It's common to write Python programs using either a text editor or an integrated development environment (IDE). An IDE is a software application that provides a comprehensive suite of tools to programmers for software development. An IDE normally consists of a source code editor, build automation tools, and a debugger. Some of them come with package managers and other features, too.

There are many Python IDE's. You can see a comparison [here](https://en.wikipedia.org/wiki/Comparison_of_integrated_development_environments#Python).

## Jupyter Notebooks

This course will be using a Jupyter Notebook to interact with Python. The bit of extra setup is well worth it because the Notebook provides code completion and other helpful features.
In this course, we interact with Python using Jupyter Notebooks. Using Jupyter Notebooks will require some extra setup. It will be well worth it, however, as Jupyter Notebooks are among the most powerful (and heavily used) tools for conducting data science in Python.

Jupyter Notebooks are included in the Anaconda distribution which you installed. Notebook files have the extension ".ipynb" to distinguish them from plain-text Python programs.

Expand Down
Loading