Data Types in python

Data type is used to specify the type and their size of data,different languages have different sizes fo the different data types

The data types of Java are classified into two types

data type is nothing but data divided into different types. We use different types of values in our programs ,like integers ,strings,float etc.so each datatype has its own reserved keyword.

Data TypeKeywordExample
integerint24,534,5,4,345
real numbersfloat1.24,2.70,424.00
charactersstr"codeskulls","amazon","zet54"
booleanTrue,FalseTrue , False
lists[ ]["turbo",2424,"car']
tuples( )("vfx","load",2424)
setsset ( )set.add(value)
dictionaries{key:value }{1:"john",2:"alex"}
NoneNoneNone

Integers

integers data type has negitivevalues and positive values including zero

x=3535

Real numbers

real numbers have decimal places and it will contain both negative and positive values

t=467.65465464

Characters

characters are maybe a single character or any string, these can be inserted in single quotes (β€˜ β€˜) or double quotes (” β€œ)

y="codeskulls"

Boolean

boolean is like 0 and 1 in binary, this is used to perform True or false actions or outputs

(3>5) #False

Lists

lists are a sequence of values of any data type, these are enclosed in square brackets ([ ]), a list is a collection of strings or numbers or both combined together and arranged in a sequence, lists are mutable, these can be modified again using commandas, lists are indexed by integers

li=[12321,"ox","jet56"]

Tuples

tuples are similar to lists but they are immutable, they can’t be changed again once they are declared. tuples are indexed by integers .tuples a be enclosed in the curved brackets

tu=(3424,"load")

Sets

set has an unordered collection of values, and they are immutable, cant add values directly, to add elements we should use set.add() command

dogs=set()

set.add("lab","milky")

Dictionaries

dictionaries are key-value pair, we can access values using little keys, Dictionary is enclosed in curly brackets { }.

dic={"1":"student1","2":"student2"}
print(dic)

None

if you dont want to assign any value to the varibale, you can use None keyword

n=None

you can check any data type using type keyword, type(variable_name)

type(n) #None
Last updated on by vishal devxo