Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
42 views

Python Bootcamp

Notes on Python Bootcamp
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
42 views

Python Bootcamp

Notes on Python Bootcamp
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 14

Python Bootcamp

Course FAQs:
Note: Many of these FAQs pertain to Notebooks, Anaconda, and Python. All of which we will discuss in
Section 2 with video content. We have videos going over all about Python and the installation process.
This FAQ is just here as a reference for you to visit whenever you wish. If you want to continue with the
course and the install procedure, continue on to the next lecture. Thanks!

1. Where can I find the Jupyter Notebooks for the Course? The course is now in Python 3, but still have
the older Python 2 notebooks available for reference in case you need them.

Python 3 Notebooks can be found here:

https://github.com/Pierian-Data/Complete-Python-3-Bootcamp

The older Python 2 Notebooks can be found here:

https://github.com/jmportilla/Complete-Python-Bootcamp

2. How do I download the Notebooks? (We show this in a video in the next section)

You can go to the GitHub page linked above and then click the download zip button to download all the
notebook (.ipynb) files onto your computer (compressed as a zip file, you'll need to unzip it). Check out
the lecture "Getting the Notebooks" for a video guide to this.

3. How do I know what directory my Notebooks are being saved?

To find out where your notebooks are type: pwd in a cell and run it with Shift+Enter. This will print your
working directory.

4. How can I change where the Notebooks are being saved?

You will need to change the directory in which you are starting you jupyter notebook. Use cd in the
terminal or command prompt to change to your desired directory if you are running jupyter notebook at
your command line. Alternatively, just navigate to your desired directory using the Anaconda Navigator
as described in the lecture "Running Python Code".

5. How do I open .ipynb files? What program do I choose? (We show this in a video in the next section)

After installing Anaconda, search your computer for Anaconda Navigator, then launch jupyter notebook
and move through the Jupyter Notebook interface until you reach your desired directory where you have
your .ipynb files. Please note, you cannot just double click a .ipynb file, it won't open that way.

Using Juptyer Notebook at your command line? Here are the instructions to open .ipynb files through
your command line:
In order to open the Notebook Files, you'll need to have Python and the Jupyter Notebook system
installed, check out the Python Set-up section for more details on the installation of Python and the
Jupyter Notebook system (or you can just follow the relevant instructions here if you feel more
technical). Once you have python and the jupyter notebooks installed you are ready to open the
notebooks using the following steps:

First open up your Command Prompt (search for cmd on a Windows machine) or if you are on a Mac use
your terminal (Spotlight search for terminal).

Next in you terminal/command prompt type pwd and press enter (this will print your working directory)

Take note of what file directory was displayed, this is where you should save your .ipynb files (or a folder
containing your .ipynb files)

Once your ipynb files or folder containing the files is in the location displayed from the pwd step go back
to your terminal and type jupyter notebook and press Enter.

After Step 4 you should have a browser tab open up with the Jupyter Notebook system running inside of
it.

Click on your Notebook (or go to your folder of Notebooks) displayed in the Jupyter Notbeook and it will
open in a new tab with the Notebook you selected.

You should now have successfully opened a Notebook file.

6. How do I get my certification?

Check out Udemy's official link on this (we don't control certification).

https://support.udemy.com/hc/en-us/articles/229603868-Certificate-of-Completion

For more questions on certification, please email support@udemy.com

7. Where can I find the slides?

https://drive.google.com/drive/folders/1CKqOQzst1cGURXGiRVivi2Xsc0n-X8CR?usp=sharing

Command line basics in Windows


cd – change directory
dir – list directory contents
cd <folder name or path> - go to specific folder or path
cls – clear screen
cd .. – go back one directory
Type the first letter of the directory then press tab to autocomplete
Lesson 1: Installing Python in Windows
*Will be using Anaconda Distribution since this is beginner friendly since it includes a lot of useful
libraries

To download Anaconda, go to: www.anaconda.com/downloads


To check documentation on Anaconda, go to: docs.anaconda.com/anaconda/install

Since we are still in the beginner phase of learning Python, it is recommended to launch Anaconda
Navigator since it’s a graphical user interface (GUI) of the various development environments that comes
with Anaconda.

On the left-hand side are the navigation tab


 Home
 Environments
 Learning
 Community
Environments are the Virtual Environments which allows you to create separate environments

We will first learn about Jupyter notebook


*note: this opens your default browser but does not actually require internet connection. It just uses the
browser to display the GUI of Jupyter. You can also modify content here, just like in your Windows
Explorer.

Notebook is where you will write your code


Once you have opened a Notebook, you can run basic mathematical operations such as addition,
subtraction, multiplication and division.

Ex. 2+3

Then select the run command or select ‘Cell’ from the Menu Bar, then select ‘Run Cells’. You can also use
the keyboard shortcut ‘ctrl + Enter’ to run the operation or code.

To enter another cell into your Notebook, press ‘Shift + Enter’

For additional information regarding Jupyter Notebook, you can select ‘Help’ in the Menu bar and then
select ‘User Interface Tour’

To close the Notebook, simply exit out of the tab in your browser, and to completely close out the
Notebook, select the ticker right beside the recently closed notebook and click on ‘Shutdown’

To delete a notebook, select the ticker beside the notebook you want to delete and then select the trash
icon

Similarly, you can delete a folder by doing the same as above but please note that you cannot delete a
folder with a content in it. It is a safety feature of Python that prevents you from accidentally deleting an
entire folder with content still in it.
No Install options for Python (Browser Based)
 jupyter.org/try
 Google Collab Online Notebooks (Google account required)
 Repl.it
 You can also Google “Python Interpreter Online” for available options

Why not just run Python in the No Install option above? It could be hard to upload your own code.
Saving your code could also be an issue since some of the No Install options requires you to pay before
proceeding to save your file.

Lesson 2: Running Python Code


3 Main Types of Environments in Python
 Text Editors
o General editors for any text file
o Work with a variety of file types
o Can be customized with plugins and add-ons
o Most are not designed as Python in mind
 Full IDEs
o Development Environment designed specifically for Python
o Larger Programs
o Only community editions are free
o Designed specifically for Python, lots of extra functionality
o Most popular IDEs for Python are PyCharm and Spyder
 Notebook Environment
o Great for learning
o See input and output next to each other
o Support in-line markdown notes, visualizations, videos, and more
o Special file formats that are not .py
o Most popular is Jupyter Notebook

Any environment is ok when you start developing

For text editors, you can use sublime text editor, which is free to try forever, it just has pop-ups asking
you to upgrade every once in a while

To run your python code in CLI (Command Line Interface), type ‘python <filename>
Or you could also develop your code in CMD or the CLI of your OS by simply typing ‘python’ and it will
open Python for you in your CLI
To quit out of the environment, type: quit () and you will return to the previous directory where you
were at before running Python.

.ipynb stand for ‘I python notebook file’, NOTE: these files cannot be opened by default in your OS, it has
to be opened through Jupyter Notebook system.
Notebook uses a cell based system where the Notebook will auto correct any syntax error with each line
of code you type in.

If you want to put in notes into your code, you can select ‘Markdown’ from the drop down selection
where you would normally see ‘Code’ in your notebook. Once you select that, you will just be typing in
regular text and your notebook will not interpret it as part of your code.

Lesson 3: Git and GitHub Overview

What is Git? Git is an online open-source distributed version control system designed to handle
everything from small to very large projects with speed and efficiency.

Git is easy to learn and has a tiny footprint with lighting fast performance. It outclasses SCM tools like
Subversion, CVS, Perforce, and ClearCase with features like cheap local branching, convenient staging
areas, and multiple workflows.

What is GitHub? It is an online repository and where you can publish your repos of your own and
collaborate with the community.

Can you use GitHub without Git? Of course, these are separate environments that you can run apart
from each other

Lesson 4: Introduction to Python Data Types

Data Types in Python


 Int – Integers. Natural Numbers
 float – Numbers with decimal points
 str – Ordered sequence of characters: ex. “Hello”
 list – Ordered sequence of objects [10,”hello”,200.3]
 dict – Dictionaries, Unordered Key:Value pairs : {“mykey” : “value” , ”name” : “Frankie”}
 tup – Tuples, Ordered immutable sequence of objects: (10,”hello”,200.3)
 set – Sets, Unordered collection of unique objects: (“a”,”b”)
 bool – Booleans, Logical value indicating True or False

Lesson 5: Python Numbers

2 main number types in Python


Integers and float

Mathematical Operators in Python


+ - * / are the basic arithmetic operators universally used (addition, subtraction, multiplication and
division)

% - mod function, used to check if a value has a remainder and will display it as its output
Ex.

** - Exponential value. It takes the first number followed by the operator ** and then raises it to the
power of the 2nd number. Ex.

Python follows MDAS when you assign multiple mathematical operators, so keep in mind that you have
to put parentheses when you want an operation to go first when running your code.

Lesson 6: Variable Assignments

Variables could be a single alphanumeric character or a string that is assigned a value


In other programming language, you have to specify which value you are going to assign in your code.

If you assign a variable a value and use that variable in an operation, it will take the current value of that
variable and then keep repeating the operation with the current value.

Ex. If you assign the variable ‘a’ with 10: a = 10, then follow your line of code with a = a + a, then it will
take the current value of 10, then add then which will output as 10, but keep in mind that if you run it
again, the current value of ‘a’ is 20, so the next output with be 40 and so on.
Use the data type: ‘type’ to check the current data type assigned to a variable

Logical operations in Python:

Lesson 6: Strings
You can use either single or double quotes to indicate a string, but if you’re going to use words that
already have a single quote like “don’t”, you should use double string to prevent Python from
prematurely closing out that string.
Use the print function to display “hello”
You can add escape sequence in Python. Ex. \n adds a new line \t for tab

- len function with count the characters


Ex. len (hello) will yield an output of 5
Please note that spaces are also counted as characters

Lesson 6: Indexing and Slicing Strings


You can use either positive indexing to grab a character which starts from the left and starts with a 0, or
or negative which starts with -1. Please see ex. where ‘Hello World’ was set as a value to the variable
mystring. After setting the value to a variable, you simply type in the variable followed by a square brace
that triggers the indexing and then put in a positive or negative value corresponding to the character
you’d like to index from the value of your variable.
Slicing is triggered similar to an index but for multiple characters in a string and you should use the colon
symbol to indicate the stop index as shown in the example below. Please note that the stop index is not
including the index you specify in your slice.

You can also run a ‘step size’ to display characters at specific intervals as shown below. Please take note
of the syntax as well where the step size is triggered by two colons:
Lesson 6: String Properties and Methods

Strings are immutable, meaning they cannot be changed once it has been assigned to a variable
Ex.

The only way to modify an existing string is to concatenate it using this syntax: <variable name> + ‘<your
edit to string>’

If you need to omit something from the existing string, you have to assign a new variable to that string
and just use indexing to extract the characters needed for the new string.
You can also use the multiplication operator to repeat the same string by x
Ex.

You can call out attributes or methods in a string variable by typing in the variable/string then add the
dot sign and press tab to show the drop down of all the attributes or methods available to the string
object.

Ex.
Keep in mind that the attribute/method doesn’t change the original string assigned to the variable. Also,
make sure to add the open and close parenthesis at the end of the syntax to execute the
attribute/method.

Ex.

You might also like