Each and every value in Python Programming language comprises of a data type. As everything in Python programming language is an object, therefore, data types are classes and the variables are referred to as an instance or objects of the classes. There are a number of Python data types. The five standard data types are as follows:
- Python Numbers (int,long,float,complex)
- Python String
- Python List
- Python Tuple
- Python Dictionary
Python Numbers (int,long,float,complex)
Defined as a complex class in Python, the Python Numbers constitute of integers, long, floating point numbers and complex numbers. Though python converts numbers from one type to the other using python variable method, it can also use these Python conversion functions such as long, complex, functions, float and integers.
We may use the type() function in order to find the to which class value or variable belongs to an instance() function to see if an object belongs to a specific class.
Example:
integer value a=200 float value b=134.2388 Complex value c=300+3k
Python Integers are limited only by the memory available and thus can be of any length.
Floating point number in python numbers is found to be accurate up to 15 decimal places. Floating points and integer are separated using decimal points
Complex numbers, on the other hand, are written in the form x+yj, where x is identified as the real part while y is considered to be the imaginary part.
Python String
String in Python is referred to as the sequence of Unicode characters. Strings can be represented using single or double quotes. However, multi-line strings are denoted using triple quotes i.e. ‘’’ or “‘“. In general, the strings are used for writing programs.
Example-
b=["Enjoy","your","Life"] print(b)
Python List
List in Python datatype refers to the ordered sequence of the items are one of the most widely used datatypes due to its flexibility. It is not necessary that all the items within the list are of the same type.
In other programming languages, lists are the Python version of arrays. Being a key tool of Python the lists can be different each time. The most vital function of the list involves the implementation of stacks and queues. These can be altered.
Declaring a list is quite simple i.e. the items distinguished using commas are written within brackets [ ].
Slicing operator can be used for the extraction of an item or range of items within a list. In Python Index begins with 0.
Example:
The list comprising of both integers and strings
p= ["We","have",2,"go keep on learning"] print(p)
Python Tuple
Similar to the lists, Tuple refers to the ordered sequence of the items with the only difference being that tuples are immutable. Once implemented Tuples cannot be amended or modified.
Tuples are utilized to write-protect data and are generally faster as compared to the list and might not change dynamically.
These are typically defined within the parentheses () where the items are separated using commas. We may use the slicing operator [ ] for extracting items but we cannot alter its value.
Example:
Tuple comprising of both integers and strings.
Tuple having both integers and strings.
p= ("We","have",2,"go keep on learning") Print (p)
Python Dictionary
Python Dictionary is the non-sequential or an unordered collection of items or key-value pairs. The factor the keeps it distinguished from other data types is the presence of key-value pairs.
In general, Python dictionary is used only when the amount of data is huge. Python dictionaries have been optimized for retrieving the data. The only thing is that one must know about how to retrieve the value.
Dictionaries in Python are denoted using braces {} with every item forming a pair in the form such as- key: value. Key is used to retrieve the respective value and can be of any type.
Example:
p = {1:"EmpName","EmpDept":"Development", "Salary":33000} print value which key is 1 Print (p[1])
Python Training in Noida
APTRON is the best Python training institute in Noida with excellent infrastructure and advanced labs to provide job oriented training that imparts professional skills to the students with live projects. The APTRON’s Python training in Noida is equipped with an interactive session and best course content to give you the best of skills and knowledge along with 100 % placement support. The institute offers best Python course in Noida at an affordable Python course fee. Industry experts with several years of expertise in the field of Python conduct the Python training course in Noida at APTRON. The classes for Python course in Noida at APTRON are held during weekdays as well as weekends both in the daytime and evening. In addition to these fast-track Python training in Noida is also provided by APTRON.