One of the most popular programming languages, used for automation, AI, building applications and websites
Python is for anyone who wants to learn it
Mosh Hamedani
Software engineer with two decades of experience, has taught over 3 million people how to code
Installing Python
1. Open browser, go to Python.org, click Downloads, download latest version, install
2. Add Python to PATH (Windows)
3. Run installer (Mac)
Installing PyCharm
Go to jetbrains.com/pycharm, download Community Edition, install
Python 2 is considered legacy and no longer maintained
Creating a new Python project in PyCharm
Create new project, name it, ensure base interpreter is set to Python 3
Writing first Python program
Create new Python file, write print statement with name, run program
Python code is executed line by line by the Python interpreter
Drawing a dog using print statements
Add additional print statements with ASCII art to draw a dog
Expression
A piece of code that produces a value
It takes 9-12 months to become job-ready with Python, including learning a specialization like web development or machine learning
Variable
A way to temporarily store data in a computer's memory
Integer
A whole number without a decimal point
Float
A number with a decimal point
Boolean
A value that can be true or false
Interpreter
Executes our code line by line from the top
Executing code
1. Set the price to 10
2. Reset it to 20
3. Print it on the terminal
Integers
Numbers without a decimal point
Floating point numbers/Floats
Numbers with a decimal point
Strings
A sequence of characters
Booleans
Values that can be true or false
Python is a case sensitive language
Simple values that can be stored in Python
Numbers (integers or floats)
Strings
Booleans
Variables
Containers that store values in the computer's memory
The input function is used to receive input from the user
Receiving user input
1. Print a message
2. Wait for user to enter a value
3. Store the value in a variable
Concatenating strings
Combines two strings into one
Calculating age
1. Get birth year from user
2. Subtract birth year from current year (2019)
3. Print the age
The input function returns a string, even if the user enters a number
int() function
Converts a string to an integer
Converting user input to integer
1. Use int() function
2. Perform calculation with integer value
Converting weight in pounds to kilograms
1. Get weight in pounds from user
2. Multiply by 0.45 to convert to kilograms
3. Print weight in kilograms
Strings
Sequences of characters that can be defined using single or double quotes
Strings can contain apostrophes or double quotes if the string is defined using the opposite type of quote
Triple quotes
Used to define multi-line strings
String indexing
Characters in a string can be accessed by their index, starting from 0 for the first character. Negative indices can be used to access characters from the end of the string.
Square brackets
Used to get a character at a given index in a string
In Python, strings are indexed starting from 0
Negative indices can be used to access characters from the end of the string