#90DaysOfDevOps
What is Python?
Python is 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?
For Windows installation click here.
For Ubuntu sudo apt-get install python3
and check the python version python3 --version
Different data types in Python
Python Numeric data types
Python numeric data type is used to hold numeric values like;
int - holds signed integers of non-limited length.
long- holds long integers(exists in Python 2.x, deprecated in Python 3.x).
float- holds floating precision numbers and it’s accurate up to 15 decimal places.
complex- holds complex numbers.
Python String Data types
The string is a sequence of characters. Python supports Unicode characters. Generally, strings are represented by either single or double quotes.
example:-
a = "String in a double quote"
b = 'String in a single quote'
Python List Data type
The list is a versatile data type exclusive in Python. In a sense, it is the same as the array in C/C++. But the interesting thing about the list in Python is it can simultaneously hold different types of data. Formally list is an ordered sequence of some data written using square brackets([]) and commas(,).
example:-
a = [1, 2, 3, 4, 5, 6] #list of having integers number
b = ["My", "name", "is", "Prabhu"] #list of having strings
c = ["Hello", 1, 2, 3, "World"]
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.
example:-
a = (1, 2, 3, 4) #tuple of having integers numbers
b = ("hello", "World") #tuple of having strings
c = ("hello", 1, 2, 3, "World") #tuple of having multiple data types
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.
example:-
a = {1: "first name", 2: "last name", "age": 33}
print(a[1]) #it will print first name
Thanks for reading this article. If you find it insightful kindly follow me.
~Prabhakar Yadav