PDA Assignments
  • Python For Data Analytics
    • 1.Python
      • 1.Python Documents
        • 1.Data Types
        • 2.Variables In Python
        • 3.Operators In Python
        • 4.User Input In Python
        • 5.TypeCasting In Python
        • 6.Strings In Python
        • 7.Conditional Statements In Python
        • 8.Branching using Conditional Statements and Loops in Python
        • 9.Lists In Python
        • 10.Sets In Python
        • 11.Tuples In Python
        • 12.Dictionary In Python
        • 13.Functions In Python
        • 14.File Handling In Python
        • 15.Numerical Computing with Python and Numpy
      • 2.Python Assignments
        • Data Type & Variables
        • Operators Assignment
        • User Input & Type Casting
        • Functions- Basic Assignments
        • String Assignments
          • String CheatSheet
        • Conditional Statements Assignments
        • Loops Assignments
        • List Assignments
          • List Cheatsheet
        • Set Assignments
          • Sets Cheatsheet
        • Dictionary Assignments
          • Dictionary Cheatsheet
        • Function Assignments
        • Functions used in Python
      • 3.Python Projects
        • Employee Management System
        • Hamming distance
        • Webscraping With Python
          • Introduction To Web Scraping
          • Importing Necessary Libraries
          • Basic Introduction To HTML
          • Introduction To BeautifulSoup
          • Flipkart Web Scraping
            • Scraping Step By Step
        • Retail Sales Analysis
        • Guess the Word Game
        • Data Collection Through APIs
        • To-Do List Manager
        • Atm-functionalities(nested if)
        • Distribution of Cards(List & Nested for)
        • Guess the Number Game
      • 4.Python + SQL Projects
        • Bookstore Management System
    • 2.Data Analytics
      • 1.Pandas
        • 1.Pandas Documents
          • 1.Introduction To Pandas
          • Reading and Loading Different Data
          • 2.Indexing and Slicing In Pandas
          • 3.Joining In Pandas
          • 4.Missing Values In Pandas
          • 5.Outliers In Pandas
          • 6.Aggregating Data
          • 7.DateTime In Pandas
          • 8.Validation In Pandas
          • 9.Fetching Data From SQL
          • 10. Automation In Pandas
          • 11.Matplotlib - Data Visualization
          • 12. Seaborn - Data Visualization
          • 13. Required Files
        • 3.Pandas Projects
          • Retail Sales Analysis
            • Retail Sales Step By Step
          • IMDB - Dataset Analysis - Basic
        • 2. Pandas Assignments
          • 1. Reading and Loading the Data
          • 2. Data frame Functions and Properties
          • 3. Series - Basic Operations
          • 4. Filtering in Pandas
          • 5. Advance Filtering
          • 6. Aggregate Functions & Groupby
          • 7. Pivot Tables
          • 8. Datetime
          • 9. String Functions
Powered by GitBook
On this page
  • Standard Data Types:
  • Type Function :
  • Numbers:
  • Assignment:
  1. Python For Data Analytics
  2. 1.Python
  3. 1.Python Documents

1.Data Types

What is Data Type?

In computer science and computer programming, a data type or simply type is an attribute of data which tells the compiler or interpreter how the programmer intends to use the data. or in more simpler terms , Data Type tells what type of Data it is.

Variables and Data Types:

Variables can hold values, and every value has a data-type. Python is a dynamically typed language; hence we do not need to define the type of the variable while declaring it.

A variable can hold different types of values. For example, a person's name must be stored as a string whereas its id must be stored as an integer.

Python provides various standard data types that define the storage method on each of them. The data types defined in Python are given below.

Standard Data Types:

  • Numbers : Integer(int) , Float(float)

  • Strings (str)

  • Boolean (bool)

  • Tuples (tuple)

  • Lists (list)

  • Sets (set)

  • Dictionary (dict)

In this lecture we will be covering Data Types related to Numbers and Strings and Boolean.

Type Function :

Type function tells what type of data a value holds.

In [1]:

type(3)

Out[1]:

int

In [2]:

type(3.5)

Out[2]:

float

Numbers:

We have two kinds of data type under Numbers : Integer (int) and Float (float).

Integer:

Integer data types are the type of data which holds positive and negative non decimal values. For Example - 1,2,3,-1,-123,-4789765,0

In [3]:

age = 24
type(age)

Out[3]:

int

Float:

Float data types are the type of data which holds positive and negative decimal values. For Example - 1.0,2.1,3.5,-1.6,-123.56,-4789765.0,0.001

In [16]:

weight = 75.0
type(weight)

Out[16]:

float

String:

The string can be defined as the sequence of characters represented in the quotation marks. In Python, we can use single, double, or triple quotes to define a string.

or in more simpler terms, anything written under single double or triple quotes are strings. For Example -'Console Flare',"Training",'''Python''','1.2',"2.33",'''4''','!@#$^&'

In [19]:

company = "console Flare"
Year = '''2021'''

Height = "6.5"

Symbol = '!@#@!'

print(type(company),type(Year),type(Height),type(Symbol))
<class 'str'> <class 'str'> <class 'str'> <class 'str'>

Boolean:

Boolean type provides two values, True and False. These values are used to determine the given statement true or false.True can be represented by any non-zero value or 'T' whereas false can be represented by the 0 or 'F'. Consider the following example.

or in more simpler terms, boolean has only two values either True or False.

Note: True and False should always be written with Capital T and F.

In [20]:

isitcold = True
type(isitcold)

Out[20]:

bool

Assignment:

  • Store an integer value in a variable name age and find its type using type function.

  • Store a number in string form so that the data type of the number is string

  • Does the data type of a variable change when the value inside the variable changes?

Previous1.Python DocumentsNext2.Variables In Python

Last updated 2 years ago