Table of contents
No headings in the article.
Let's Start with the Basics of Python as this is also important for DevOps engineers to build the logic and Programs.
What is Python?
Python is an Open source, general-purpose, high-level, and object-oriented programming language.
It was created by Guido van Rossum
Python consists of vast libraries and various frameworks like Django, Tensorflow, Flask, Pandas, Keras etc.
How to Install Python?
You can install Python in your System whether it is Windows, MacOS, ubuntu, centos etc. Below are the links for the installation:
Ubuntu: apt-get install python3.6
Task1:
Install Python in your respective OS, and check the version
Windows:
Visit the official Python website at https://www.python.org/downloads/.
Download the latest version of Python for Windows.
Run the installer and select the option to install Python.
Make sure to check the box that says "Add Python to PATH" during the installation process.
Follow the prompts and complete the installation.
Once installed, you can check the version of Python by opening the Command Prompt and typing the following command:
python --version
Mac:
Open a web browser and go to the official Python website at https://www.python.org/downloads/.
Download the latest version of Python for macOS.
Run the installer package.
Follow the prompts and complete the installation.
To check the version of Python, open the Terminal and type the following command:
python3 --version
Linux (Ubuntu):
Open a terminal.
Update the package index using the following command:
sudo apt update
- Install Python by running the following command:
sudo apt install python3
- Once the installation is complete, you can check the version of Python by typing the following command:
python3 --version
Please note that the specific commands and steps may vary depending on your operating system version or distribution.
Read about different Data Types in Python.
In programming, the data type is an important concept.
Variables can store data of different types, and different types can do different things.
Python has the following data types built-in by default, in these categories:
Text Type:
str
Numeric Types:
int
,float
,complex
Sequence Types:
list
,tuple
,range
Mapping Type:
dict
Set Types:
set
,frozenset
Boolean Type:
bool
Binary Types:
bytes
,bytearray
,memoryview
None Type:
NoneType
Numeric Types:
int: Integer values like 1, 2, -3, etc.
float: Floating-point numbers with decimal points like 3.14, -2.5, etc.
complex: Complex numbers in the form of a + bj, where a and b are real numbers and j is the imaginary unit.
Boolean Type:
- bool: Represents boolean values, either True or False.
Sequence Types:
str: Represents a sequence of characters, such as "Hello, World!".
list: An ordered collection of items, enclosed in square brackets ([]), e.g., [1, 2, 3].
tuple: Similar to a list, but enclosed in parentheses (()), and its elements are immutable (cannot be changed).
Mapping Type:
- dict: Represents a collection of key-value pairs enclosed in curly braces ({}) or created using the dict() constructor.
Set Types:
set: An unordered collection of unique elements enclosed in curly braces ({}).
frozenset: Similar to a set, but its elements are immutable.
None Type:
- None: Represents the absence of a value or a null value.