In the previous blog on Python To Represent Outputs we have learned about the representation of outputs & the cause of slow execution of python than binary.
Python is loved by developers due to lots of reasons. One cause is readability & fast development of code. Have you ever thought about why development in python is so fast? Let’s understand the cause of fast development in Python…
Currently, Python occupies a very large space in the Technical domain. Definitely, Python has a very large community that maintains it continuously. Python communities are always trying to make it as simple as possible so that learning becomes easy.
Python contains a lot of domain-specific libraries, modules, functions which helps it to become multi-purpose. These pre-created functions help to reduce the lines of code. For a developer, these pre-created functions become the front face while in the background there is lots of basic code working behind the scene to give the desired output.
Let’s move ahead with our experiences & learn things faster like Python…
type(): This function used to find the identity of an entity. The class of data type in which an entity exists. It takes only a single argument.
Literals: Data itself called Literals. It is fixed. It is an Independent Entity.
print(786) 786 type(786) <class 'int'>
print("Priyanshu Gupta") Priyanshu Gupta type("Priyanshu Gupta") <class 'str'>
Variables: Variables are like containers for data. They have their own identity due to the type of data that they contain. Type of Data changed then the identity also changed. It is a Dependent Entity.
print(C) Traceback (most recent call last): File "<stdin>", line 1, in <module> NameError: name 'C' is not defined
As you can see C has no identity. We need to define its identity to operate it.
Assignment Operator : (Variables = Literals)
It is represented using the “ = ” sign. To define variables with Literals, we use it.
(For different types of operations there are different types of operators in python. Don’t worry we will learn them later.)
Example: An Entity like 786, “Priyanshu Gupta” is fixed data called Literals while C can represent anything like Constant in Mathematics, Speed of Light in Physics called Variables.
C="Priyanshu Gupta" print(C) Priyanshu Gupta type(C) <class 'str'>
Here, C got an identity of Class String. It proves that An Entity must have an identity of a Class of Data type to be operated.
C=786 print(C) 786 type(C) <class 'int'>
Let’s move to Classes of Data Types...Here, the identity of C is changed in another integer type of data. It proves the variable nature of this type of entity.
Every data belongs to a specific group. Every operation in every Class may not be performable. It will be more clear to you while we will learn about operators.
Mathematically, an integer is a number without a fractional part.
a=3 type(a) <class 'int'>
Convert Binary, Octal & Hexadecimal Numbers into Decimal Number:
Binary numbers lie between 0 to 1. Here, 0b is a converter.10101 =
a=0b10101 print(a) 21 type(a) <class 'int'>
Octal numbers lie between 0 to 7. Here, 0o is a converter.
a=0o420 print(a) 272 type(a) <class 'int'>
Hexadecimal numbers lie between 0 to 15, where Here, 0x is a converter.
a=0x7AF print(a) 1967 type(a) <class 'int'>
Mathematically, a float is a number with a fractional part but Python only needs a single dot (.) to treat a number as float.
a=3.0 type(a) <class 'float'>
In calculators, many times you see “E” between digits. It appears when a very large number appears in calculations. E represents base 10 of forwarding Power digit.Light Speed = 300000000 m/s = 3E8 m/s
a=3E8 print(a) 300000000.0 type(a) <class 'float'>
In simple words, String is a pair of characters. There are 3 ways to represent an string . Everything between quotes is data.
It can be called as Single quotes.
a='KingsMan' print(a) KingsMan type(a) <class 'str'>
a="KingsMan" print(a) KingsMan type(a) <class 'str'>
Because when a need appears to use quotes between strings then programs get confused about start & end of strings. To resolve it we can use 2 ways
Use Double in Single quotes & Single in Double quotes.
Use Escape Character \ before Internal quotes.
print("2020 brings "COVID" as Evil. ") File "<stdin>", line 1 print("2020 brings "COVID" as Evil. ") ^ SyntaxError: invalid syntax print("2020 brings 'COVID' as Evil. ") 2020 brings 'COVID' as Evil. print("2020 brings \"COVID\" as Evil. ") 2020 brings "COVID" as Evil. print('2020 brings 'COVID' as Evil. ') File "<stdin>", line 1 print('2020 brings 'COVID' as Evil. ') ^ SyntaxError: invalid syntax print(" 2020 brings 'COVID' as Evil. ") 2020 brings 'COVID' as Evil. print('2020 brings \'COVID\' as Evil. ') 2020 brings 'COVID' as Evil.
To pass Multiple lines of strings in a single function we use Triple Quotes.
a="""KingsMan Priyanshu Gupta""" print(a) KingsMan Priyanshu Gupta type(a) <class 'str'>
Boolean values decide the flow of programs to move in a direction. Only things that matter in boolean is True & false. True can be represented as 1 and False as 0 in a decision making result.
a=True print(a) True type(a) <class 'bool'>
As you can see that the only 2 strings which can be used as values without any single, double or triple quotes are True & False in Python.
a=False print(a) False type(a) <class 'bool'>
Development in Python is fast & don’t misconceptualized it with Speed of execution.
We will clearly understand that development depends on how developers can write source codes for a Task. In Python Line of codes are definitely less than others for the same task.
To deal with various types of data we have learned about different classes of data types. It will help us to recognize the data as well as which type of operations we can perform on it. Python has a lot of classes of data types. But we have read a few classes which have a major role, rest of the classes we will recognize where it is needed.
“ Python is Smart who moves ahead with the experience of others rather than researching everything from the start. ”
6 Major Branches of Artificial Intelligence (AI)READ MORE
Reliance Jio and JioMart: Marketing Strategy, SWOT Analysis, and Working EcosystemREAD MORE
Top 10 Big Data TechnologiesREAD MORE
8 Most Popular Business Analysis Techniques used by Business AnalystREAD MORE
Elasticity of Demand and its TypesREAD MORE
What Are Recommendation Systems in Machine Learning?READ MORE
An Overview of Descriptive AnalysisREAD MORE
Deep Learning - Overview, Practical Examples, Popular AlgorithmsREAD MORE
7 Types of Activation Functions in Neural NetworkREAD MORE
What is PESTLE Analysis? Everything you need to know about itREAD MORE