Python Crash Course: Learn Python Quickly

Share on facebook
Share on twitter
Share on linkedin
Python crash course

Congratulations! It looks like you’ve decided to learn Python. You’ll be so happy with your decision to trust this Python crash course to make learning the new language easy.

Python is a fairly intuitive language, but there are some changes to those that are learning it for the first time. The good news, if this is your first language, is that it’s harder to switch from others than to start from scratch!

In this crash course, we’ll learn about Libraries, Formatting, If Statements, and For Loops for Python. Let’s get started!

1. Python Libraries

Python Libraries are groups of code that better Python programmers have made to help you! They’re pretty amazing and can be added to your code really quickly.

You can quickly add advanced code into your project that would have taken you 3 months to write and impress your coworkers like you wrote it yourself.

Looking to scrape Twitter? There’s a library for that.

Looking to make heatmaps? There’s a library for that.

You get the point. You can call new libraries by typing the following code at the beginning of your script.

import pandas as pd

In your code, you can now use Pandas, a very famous data science library, in your program.

2. No Semicolons

While most coding languages end with a semicolon at the end of every line of code, Python doesn’t. The end of each statement of code ends with no semicolon.

For new coders, this won’t phase you; however, if you are a seasoned coder, it can be upsetting.

You would write a print statement like this:

print("Hi, I have no semicolons. I'm sorry if that upsets you") 

3. Whitespace

Another big distinction between Python and any other coding language is that Python doesn’t use brackets in its code. Instead, it uses whitespace to imply a relationship between a statement and the code inside of it.

By adding an indent, you can imply that code should be ran based on a condition or continuously many times.

As you test out code, remember that an indent can change your code a lot

list = [0, 1, 2, 3] 
for number in list: 
    print("For Loop") 
Due to the indent, this will run 4 times for each #number and print "For Loop" 4 times print(number)
list = [0, 1, 2, 3] 
for number in list: 
print("No number printed")
Since this print statement is outside the for loop, it will only print "No number printed" once 4 blank lines are printed.

4. Introduction to If Statements

If Statements check whether or not a statement is true and only continues if it is True.

kevins_age = 22
if kevins_age == 22: 
     print("Kevin's age is 22") 
     print("Kevin's age is not 22")

Since the statement above is True, this will print “Kevin’s age is 22”. Since the statement above is True, the else statement will not run.

5. For Loop Tutorial

For loops are statements in Python that iterate across other statements multiple times until a condition is no longer True.

You can do things that would take you a lot of time over and over again based on different conditions.

The simple for loop

list = [1, 2, 3, 4]
for number in list: 

The while loop: continue until a condition is proved False number = 0 # instantiate the variable number as a zero # Continue the code inside the indent, while the number is less than 10 while number < 10: # print the number print(number) # increase the number by 1 number += 1 #

Warning!! # With this while loop, you need to be careful not to create an “Infinite Loop” # If you did not add the 1 to number, this would continue forever.

Other Python Crash Courses

I’d recommend Codecademy and Datacamp if you’re looking for more in-depth Python crash courses.

If you feel ready to test some of these concepts in your own personal environment, here is how to setup Python on your own computer in 17 minutes.