Data Types In Python

When we work with any programming language, we need to use data types in order to store data in memory with variables. Based on our need we need to declare the data type.

Below are the list of Data Types in Python :
String
Numbers
List
Tuple
Dicitionary

  1. String : Strings in Python is a continuous sequence of characters enclosed within single or double quotes. Always the string index starts from Zero.

String Example In Python :


OUTPUT :

Python_String_Example

2.Numbers : Numbers data type of Python will store numeric values. Number object will be initiated or comes into action as soon as we assign a value to the numbers.

Numbers Example In Python :

OUTPUT :

Numbers In Python

3.Python Lists :Lists in python can contain multiple data types. List will contain values separated by commas within square brackets []. The values within list starts from the index zero.

List Example In Python :


OUTPUT :

Python_List_Example

4.Python Tuples :Tuple is also similar data type as List. We can store values in Tuple using parenthesis. We cannot update the Tuple with values, it’s a static one, meaning if we declare 3 values in Tuples we cannot add the 4th value in the Tuple.

Tuples Example In Python :

OUTPUT :

Tuples Examples In Python

  1. Python Dictionary : Python Dictionary is similar to Hash Table in Java. In other words, it works in the form of Key, value pairs. If we want to access any value from the Dictionary then we should know the Key of that particular pair. Dictionary is enclosed within curly braces.

Dictionary Example In Python :

prints studID value “098”

print (dict.keys()) # prints all the keys values available in dictionary

print (dict.values()) # prints all the valuesavailable in dictionary

OUTPUT:

Leave a Comment

Your email address will not be published. Required fields are marked *