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 Type | Keyword | Example |
---|---|---|
integer | int | 24,534,5,4,345 |
real numbers | float | 1.24,2.70,424.00 |
characters | str | "codeskulls","amazon","zet54" |
boolean | True,False | True , False |
lists | [ ] | ["turbo",2424,"car'] |
tuples | ( ) | ("vfx","load",2424) |
sets | set ( ) | set.add(value) |
dictionaries | {key:value } | {1:"john",2:"alex"} |
None | None | None |
Integers
integers data type has negitivevalues and positive values including zero
Real numbers
real numbers have decimal places and it will contain both negative and positive values
Characters
characters are maybe a single character or any string, these can be inserted in single quotes (β β) or double quotes (β β)
Boolean
boolean is like 0 and 1 in binary, this is used to perform True or false actions or outputs
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
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
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 { }
.
None
if you dont want to assign any value to the varibale, you can use None keyword
you can check any data type using type keyword, type(variable_name)