Python Data Types
Python Data Types
1. Numbers
2. Sequence Type
3. Boolean
4. Set
5. Dictionary
Numbers
Output:
The type of a <class 'int'>
The type of b <class 'float'>
The type of c <class 'complex'>
c is complex number: True
Sequence Type
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.
Example - 1
Output:
he
o
hello javatpointhello javatpoint
hello javatpoint how are you
List
Lists are used to store multiple items in a single
variable.
Example
Create a List:
thislist = ["apple", "banana", "cherry"]
print(thislist)
Output
['apple', 'banana', 'cherry']
Python Tuples
Tuple
Tuples are used to store multiple items in a single
variable.
Tuple is one of 4 built-in data types in Python used to
store collections of data, the other 3 are List, Set,
and Dictionary, all with different qualities and usage.
Example
Create a Tuple:
thistuple = ("apple", "banana", "cherry")
print(thistuple)
Output
{'banana', 'cherry', 'apple'}
Python Sets
Set
Sets are used to store multiple items in a single
avariable.
Example
Create a Set:
thisset = {"apple", "banana", "cherry"}
print(thisset)
Dictionary
Dictionaries are used to store data values in key: value
pairs.
Example
Python Booleans
Boolean Values
In programming you often need to know if an
expression is True or False.
Example
print(10 > 9)
print(10 == 9)
print(10 < 9)
Output
True
False
False