The real world use of data types and why we need it?
The case study of data types
Introduction
Data types manipulate the programming realm irrelevant of the language. It gives value to the variable and numbers. Here we are going to see the use case of data types and how to use them. when it comes to learn programming language topics like variables, datatypes, oops, functions, loops and list goes infinitely. To inculcate each topic, you have to reinforce the concepts delibrately.
Why python?
Python is a go to language for plethora of applications. Due to its fastest growth python is an inevitable language in tech industry. The python applications are countless. Here are some applications in business to make smart decisions. User friendly GUI apps with help of python frameworks. In AI and data science to automate real world tasks. Ok let’s start.
Data types in action
Before we begin, we need to understand some glossary.
Value-the basic units of data. for instance, number or string
Variables -it gives name to the value
Data types- a category of values(int,float bool.. etc)
The basic data types are
Integer
The integers are signed whole numbers. Signed means either like positive or negative. whole means except fractional numbers. Ex: 54,22
Float
The floats are like integers except it can store fractional numbes. It gives more accurate precise answers than integers can. Ex: 12.3, 5e
Strings
Strings are sequence of characters. Ex: hello,python
Note: we are covering only basic data types. there are other data types like lists, set, tuples and arrays which is not covered.
Lets’s assign a variables
#strings are enclosed in double quotes or single quotes
myname = "python"
your_name = 'java'print(myname)
print(your_name)output:
python
java
Use-case
python was famous for automation via scripts. we can send emails with python. for example, imagine we send greetings for party. We have to send greetings for many colleagues. so, type their name individually and put a specefic year is a daunting task. See the code below:
print(" hi jack welcome to the 2020 freshers party")
print(" hi maria welcome to the 2020 freshers party")
print(" hi anna welcome to the 2020 freshers party")
print(" hi mega welcome to the 2020 freshers party")
Here typing their name and specific year is a rigorous task for us. Here what data types come into play.
name = "jack"
year = 2020print("hi," name "welcome to the" year "freshers party")
Instead of copy paste and typing give a variable name and data type for lot easier for us. you can benefit lot from this. you can also do this for brief paragraph. it is somewhat similar like find and replace.