What is Python?
Python is a computer programming language often used to build websites and software, automate tasks and conduct data analysis.
It is a general-purpose language, meaning it can be used to create a variety of different programs and isn’t specialized for any specific problems.
How it is useful for DevOps?
Python is one of the best programming languages for Automation in DevOps.
DevOps teams use Python for automating repetitive tasks, infrastructure provisioning, and API-driven deployments. CI/CD workflows and much more.
Installation:
You can install Python in your System whether it is Windows, MacOS, ubuntu, centos etc. Below are the links for the installation:
Windows installation
Ubuntu: apt-get install python3.6
Task1:
- Install Python in your respective OS, and check the version.
I have installed it on Windows.
Read about different Data Types in Python.
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:
- 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.
1. Python Numeric Data Type:
Python numeric data type is used to hold numeric values like;
int -
holds signed integers of non-limited length.
float-
holds floating precision numbers and it’s accurate up to 15 decimal places.
complex-
holds complex numbers.
2. Python String Data Type:
The string is a sequence of characters. Python supports Unicode characters. Generally, strings are represented by either single or double quotes.
a = "Hello everyone"
b= 'I am NamG'
print(a)
print(b)
Python List Data Type:
Lists are just like arrays, declared in other languages which is an ordered collection of data. It is very flexible as the items in a list do not need to be of the same type. Lists are mutable.
Lists in Python can be created by just placing the sequence inside the square brackets[ ].
list of having only integers:
a= [1,2,3,4,5,6]
print(a)
list of having only strings:
b=["hii","hello","good"]
print(b)
list of having both integers and strings
c= ["hello","name",1,2,3]
print(c)
4. Python Tuple:
The tuple is another data type which is a sequence of data similar to a list but it is immutable. That means data in a tuple is write-protected. Data in a tuple is written using parenthesis ( ) and commas.
#tuple having multiple type of data.
b=("hello", 1,2,3,"namg")
print(b)
5. Python Dictionary:
Python Dictionary is an unordered sequence of data of key-value pair form. It is similar to the hash table type. Dictionaries are written within curly braces in the form key: value. It is very useful to retrieve data in an optimized way among a large amount of data.
a = {"firstname":"sayali","last name":"shewale", "age":25}
print value having key=1
print(a[1])
print value having key=2
print(a[2])
print value having key=3
print(a[3])
Top comments (0)