PYTHON
Why Python?
Python is one of the most popular programming languages in the world. One of this language’s advantages is that its syntax is very simple. For example, for a very basic program where you make the words “Hello World!” appear on the screen, the code for Python would look like this:
print("Hello World!")
Whereas in Java, the code would look like that:
Installation
Python can be installed from this link:
https://www.python.org/downloads/
You will also need a text editor to write your program on. Here are a few that are free:
-
Python IDLE: Included when you install Python, its IDLE isn’t very performant, but it works if you don’t often code with Python. However, if you use it often, we recommend using one of the following options.
-
Pycharm Community Edition (recommended): One of the most performant free editors. Use this link to install: https://www.jetbrains.com/pycharm/download/
-
Visual Studio Code: Another popular text editor, Visual Studio Code was created by Microsoft and offer many services: https://code.visualstudio.com/download
What does it mean to know Python’s basics?
To be able to say that you know Python s basics, you must be able to comfortably use the following:
-
Input, print
-
Ints, floats, strings
-
Conditions: if, else
-
Loops: for and while loops
-
Lists (arrays)
-
Functions
-
Dictionaries
-
Classes if you are interested in doing object-oriented programming
Visit the “Resources" section to learn Python's basics.
Libraries
After learning the basics of Python, importing libraries to your program is easy and it can help you make your program better. Here are a few examples of Python libraries and what they can do:
-
Requests and BeautifulSoup let you do web scraping (take information from a website and add it to your program). However, you must have a basic knowledge of HTML.
-
Openpyxl helps you import or export data from/to Excel files
-
Tesseract OCR (https://github.com/tesseract-ocr/ tesseract) lets you convert an image of a text to text.
-
Pillow lets you open and edit images.
-
Matplotlib and Plotly can help you make graphs and charts that look great.
-
Tensorflow is a machine learning (AI) library, for advanced programmers.
-
& many, many more
Installing libraries
To install librarires, you will need to use pip and you might need to download the library from the internet (as for Tesseract). Here are the steps (you might have to replace pip by pip3 ):
On Windows
To install libraries, you will need to use pip and you might need to download the library from the internet (as for Tesseract). Here are the steps:
-
Choose which library you wish to use
-
In your command prompt, type pip install + the name of your library.
-
If step 2 doesn't work, add pip to your PATH. See https://appuals.com/fix pip is not recognized as an internal or external command/ to add pip to your PATH. Retry step 2 if this doesn't work.
-
If step 3 doesn't work, typing one of these 3 should work: py m pip install + name of the library, python m pip install + name of the library or python3 m pip install + name of the library.
On macOS
To install libraries, you will need to use pip and you might need to download the library from the internet (as for Tesseract). Here are the steps (you might have to replace pip by pip3):
-
Choose which library you wish to use.
-
In your command prompt, type pip install + the name of your library.
If you encounter any problems, the best way to remedy them is by searching your error on the Internet.
Resources to learn Python:
-
https://www.codecademy.com/ (not free)
We also recommend using online videos to learn programming. Here are a few popular Youtube programming channels.
-
freeCodeCamp
-
Corey Schafer
-
sentdex
-
Programming with Mosh
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello World!");
}
}