- Let's Start with Basics of Python as this is also important for Devops Engineer to build the logic and Programs.
What is Python?
Python is a high-level programming language that was first released in 1991. It was created by Guido van Rossum and is now maintained by the Python Software Foundation.
Python is a high-level, interpreted programming language that emphasizes simplicity, readability, and ease of use. It is widely used for web development, scientific computing, data analysis, and machine learning, among other applications, and is known for its vast library of modules and ease of integration with other languages and tools.
How to Install Python?
You can install Python in your System whether it is window, MacOS, ubuntu, centos etc. Below are the links for the installation:
-
ou can install Python on Windows 10 by following these steps:
Go to the official Python website at python.org/downloads.
Click on the "Download Python" button for the latest version of Python (currently version 3.11.2 as of my knowledge cutoff date).
Scroll down to the "Files" section and click on the appropriate installer for your system (32-bit or 64-bit). If you're not sure which one to choose, select the 64-bit version.
Once the installer has downloaded, run it by double-clicking on the file.
Follow the prompts in the installation wizard to install Python. During the installation, you may be prompted to customize the installation or choose additional features; you can usually just leave the defaults and continue.
Once the installation is complete, you should be able to run Python by opening the Command Prompt and typing "python" (without the quotes) at the prompt. If Python is installed correctly, you should see the Python version number displayed.
Congratulations, you have successfully installed Python on Windows 10
Task 1:
Install Python in your respective OS (Ubuntu), and check the version.
Update the package list to ensure that you get the latest version of Python.
Type the following command and press Enter:
sudo apt update
Install Python 3 by typing the following command and press Enter:
sudo apt install python3
Verify the installation by typing the following command and press Enter:
python3 --version
This will display the version of Python that you have installed.
(Optional) You can also install pip, which is the package installer for Python, by typing the following command and press Enter:
sudo apt install python3-pip
Once you have installed pip, you can use it to install packages for Python.
That's it! You now have Python installed on your Ubuntu system.
Read about different Data Types in Python.
Python has several built-in data types that are used to represent different kinds of data. These include:
Numeric data types: Numeric data types in Python are used to represent numbers. There are three main types of numeric data types in Python:
a. Integer (int): This data type is used to represent whole numbers, both positive and negative, without any decimal point.
b. Float (float): This data type is used to represent floating-point numbers, which are numbers that have a decimal point.
c. Complex (complex): This data type is used to represent complex numbers, which are numbers that have a real and imaginary part.
String data type: String data type in Python is used to represent a sequence of characters. A string is enclosed in quotation marks (' ' or " ").
Boolean data type: Boolean data type in Python is used to represent the truth value of an expression. It has only two possible values: True or False.
List data type: A list is an ordered collection of elements, which can be of different data types. Lists are mutable, which means that you can change the elements of a list.
Tuple data type: A tuple is an ordered collection of elements, similar to a list. However, tuples are immutable, which means that you cannot change the elements of a tuple once it is created.
Set data type: A set is an unordered collection of unique elements. Sets are mutable, which means that you can add or remove elements from a set.
Dictionary data type: A dictionary is an unordered collection of key-value pairs. Each key in a dictionary must be unique, and the keys are used to access the corresponding values.
These are some of the most commonly used data types in Python. By understanding these data types, you can write more effective and efficient Python programs.
Happy Learning