python 3
python 3
This site uses Google AdSense ad intent links. AdSense automatically generates these links and they may help creators earn
money.
Data Types
Data type specifies the type of value a variable requires to do various operations
without causing an error. By default, python provides the following built-in data
types:
Boolean data:
Boolean data consists of values True or False.
Output:
[8, 2.3, [-4, 5], ['apple', 'banana']]
Output:
range: returns a sequence of numbers as specified by the user. If not specified by the
user then it starts from 0 by default and increments by 1.
Example:
sequence1 = range(4,14,2)
for i in sequence1:
print(i)
Output:
4
6
8
10
12
Output:
b'This is a string'
b'\xff\xfeT\x00h\x00i\x00s\x00 \x00i\x00s\x00 \x00a\x00 \x00s\x00t\x00r\x0
b'\x00\x00\x00\x00'
Output:
bytearray(b'This is a string')
bytearray(b'\xff\xfeT\x00h\x00i\x00s\x00 \x00i\x00s\x00 \x00a\x00 \x00s\x0
bytearray(b'\x00\x00\x00\x00')
Output:
Set data:
Set is an unordered collection of elements in which no element is repeated. The
elements of sets are separated by a comma and contained within curly braces.
Example:
Output:
{2.9, 3, 4, 8, -5}
None:
None is used to define a null value. When we assign a None value to a variable, we are
essentially resetting it to its original empty state which is not the same as zero, an
empty string or a False value.
Example:
state = None
print(type(state))
Output:
<class 'NoneType'>