2. Data Types in Python
Fundamentals Derived
Integers
Float
Complex
Boolean
String
None
List
Tuple
Range
Bytes
Bytes Arrays
Set
Frozen Set
Dictionary
Suite
Numbers
Sequence
Sequence
Mapping
3. To convert any number from binary, octal, hexadecimal to
decimal value just assign the value to a variable with
corresponding prefixed and peint it. It will give you decimal
equivalent of that number.
Base conversion
Basic Conversion
Bin(X)
Here argument
(x) can be a
decimal, octal
or hexadecimal
value anything
oct(X)
hex(X)
4. Data type with one of the two built-in values, True or False.
Boolean objects that are equal to True are truthy (true).
But non-Boolean objects can be evaluated in Boolean
context as well and determined to be true or false. It is
denoted by the class bool.
Boolean
# Python program to
# demonstrate boolean type
print(type(True))
print(type(False))
print(type(True))
5. Boolean Data Type in Python
Note – True and False with capital ‘T’ and ‘F’ are valid
booleans otherwise python will throw an error.
Boolean in python
True
False
- Except 0 everything is true
- Except empty string
everything is true
True - 1
False - 0
6. In Python, Strings are arrays of bytes representing
Unicode characters.
A string is a collection of one or more characters put
in a single quote, double-quote or triple quote.
In python there is no character data type, a
character is a string of length one.
It is represented by str class.
Strings in Python
7. Strings in Python
Strings
Combination of characters
kept inside
single/double/triple quotes.
Triple quotes are used to
-To define multiline string,
-To define docstring.
-To comment multiple
lines.
Indexing - str[index]
Slicing - [start:end:step]
Few basic operation on
string.
-Concatenation.
-Repetition.
8. Data Types in Python
Mutable vs Immutable Data
type in Python
Stay Tuned with
Topics for next Post