Why Python?
Python is a clear and powerful interpreted, general purpose, object-oriented programming language with classes and multiple inheritances. Python is a dynamically typed and garbage collected language. Why dynamic? We don't have to declare the type of a variable while assigning a value to a variable in Python.
- A variety of basic data types are available: numbers (floating point, complex, and unlimited-length long integers), strings, lists, and dictionaries.
- Clean error handling
- Memory management, involving a private heap containing all Python objects and data structures.
- Python uses an elegant syntax, making the programs you write easier to read, easy to test and it runs anywhere, including Mac OS X, Windows, Linux and Unix.
- Python is free to use and is available under open source.
Use cases:
Python is a multipurpose programming language. You can use Python for, but not limited to:
- Machine learning and AI. Python is the number 1 programming language for machine learning and data science.
- Web development.Using Python and a framework called Django.
- Automation
Setting up
You need to install Python 3 interpreter in your computer. This will read and execute our Python programs. Python 3.10 is the latest version with the latest features. This article uses Python 3.8 (which is the latest security release), in the conda environment.
Read more about setting up the environment here
Hello World!
Whatever your reason for learning Python is, it's possible. We shall kick off the journey with our first app.
Run python
Once the installation is complete you can run python.
-
Running Python in the terminal by typing
python
and writing python code next.
eazzy@eazzy-HP-ProDesk-400-G3-MT:~$ conda activate my_env
(my_env) eazzy@eazzy-HP-ProDesk-400-G3-MT:~$ python
Python 3.8.12 (default, Oct 12 2021, 13:49:34)
[GCC 7.5.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> print('hello world')
hello world
>>>
Type quit()
to exit python if you wish to.
- Run Python in Integrated Development Environment (IDE)
Prerequisites
Specifically, we require:
VS Code
VS Code Python extension
Create an empty directory called hello
In it we will create our python file. A python file file has a .py extension. Open in vs-code.
From the File Explorer toolbar, select the New File button on the hello folder. Name the file hello.py
, and it automatically opens in the editor.
msg = "Hello World"
print(msg)
Click the Run Python File in Terminal play button in the top-right side of the editor.
You will get the following output.
Happy dance! We just wrote our first program in Python.
There is then much more to explore with Python in Visual Studio Code.
Next we shall learn about the basics of python.
Resources
Reference
BeginnersGuide
PythonChecker Makes Your Code Great Again
Top comments (0)