Let's begin by covering the fundamentals of Python, as it plays a crucial role in enabling DevOps engineers to develop logic and programs.
What is Python?
Python is an open-source, high-level, versatile, and object-oriented programming language. It was created by Guido van Rossum in the late 1980s and was first released in 1991.
Python has gained widespread popularity and is known for its simplicity and readability, making it a preferred choice for many developers.
Python is used in various applications and industries, including:
Web Development: Frameworks like Django and Flask are used to build web applications.
Data Science: Python is widely used for data analysis, machine learning, and artificial intelligence with libraries like Pandas, NumPy, TensorFlow, and scikit-learn.
Automation: It's used for scripting and automating repetitive tasks and system administration.
Game Development: Python is used for game development, often with libraries like Pygame.
Scientific Computing: It's used in scientific research and simulations.
Desktop Applications: Tools like Tkinter and PyQt enable the development of desktop applications.
Embedded Systems: Python can be embedded in hardware devices for control and automation.
DevOps: Python scripts are commonly used for tasks like configuration management, deployment automation, and monitoring.
Education: Python is frequently used for teaching programming due to its simplicity.
Python's versatility, large standard library, and active community make it a popular choice for a wide range of applications and industries.
How to Install Python?
Installing Python is a straightforward process. Begin by visiting the official Python website at https://www.python.org/ and proceed to the "Downloads" section.
Once on the website, you'll find a selection of installers tailored to different operating systems. Choose the installer that corresponds to your specific operating system. It is strongly recommended to opt for Python 3 since Python 2 is no longer supported. Select the latest available version of Python 3.
For Linux users, you have the flexibility to install Python via your distribution's package manager. Alternatively, you can download the source code or explore alternative installation methods.
To ensure a successful installation, perform a quick verification. Open a command prompt or terminal and enter python --version
or python3 --version
(for Python 3) to confirm the installation, with the version number prominently displayed.
Task:
1:Install Python in your respective OS, and check the version.
We can verify the installation using Python3 --version command.
2:Read about different Data Types in Python.
Numeric Data Types:
Integers (int):
Holds signed integers of non-limited length.
Example:
x = 28
Floating-Point Numbers (float):
Holds floating decimal points with precision up to 15 decimal places.
Example:
p = 2.764
Boolean
Store only True or false value
Example is_rainging = False
String Data Type:
Strings in Python are sequences of characters represented by either single or double quotes.
Python List:
An ordered collection of similar or different types of items. Enclosed within brackets
[ ]
.- Example:
test_list = [10, 20, 'Anurag', 4.0]
- Example:
Python Tuple:
Similar to a list but immutable.Once created, tuples cannot be modified.
Enclosed within parentheses
( )
.- Example:
test_tuple = (300, 202, 'Data', 4.0)
- Example:
Python Dictionary:
An ordered collection of items stored in key/value pairs. Keys are unique identifiers associated with each value.
Enclosed within curly braces
{ }
.Example:
diwali_sweets = {'Sonapapadi': '10', 'Laddu': 50, 'Gulab-jamun': [11, 22, 33]}
Example of test Python file for data variables
Thanks,
- Kishor Chavan