Numbers: int, float, complex
## integer, long, float, complex
List:
Ordered sequence of items
Tuple:
Ordered sequence of items similar to list but is immutable
Strings
: Sequence of characters
Sets: Unordered collection of unique items
Dictionary: unordered collection of key-value pairs

Mutable Objects

Immutable Objects

Can change their state or contents

Cannot change their state or contents

Type: list, dict, set

inbuilt types: int, float, bool, string, unicode, tuple

Easy to change

Quick to access but making changes require creation of copy

Customized container like types of mostly mutable

Primitive like data types are immutable

tuples are immutable but may contain elements that are mutable

#!/usr/bin/env/python3
# This program is on data types
a=5
print(a)
type_a=type(a)
print(type_a)
print('')
b=5.0
print(b)
type_b=type(b)
print(type_b)
print('')
c=65535
print(c)
type_c=type(c)
print(type_c)
print(' ')
d=65535*65335
print(d)
type_d=type(d)
print(type_d)
print('')
print ('0b11001 is binary 25')
e=0b11001
print(e)
type_e=type(e)
print(type_e)
print('')

# \' allows the ' in can't
string_a='I can\'t believe this'
print(string_a)
type_str_a=type(string_a)
print(type_str_a)
print('')
#Convert numeric type to another
f=15
print(f)
print(type(f))
print('')
print(float(f))
print(type(float(f)))
print('')
print(str(f))
print(type(str(f)))
print('')
a = 7
b = -8
print(complex(a,b))
print(type(complex(a,b)))
x = complex(a,b)
print("Real: {} Imaginary: {}".format(x.real, x.imag))
print("")
a = ~5
print("~x = -(x+1) = -6 so x = 5")
print("~5 is {}".format(a))
a = ~~5
print("~~x = -(x+1) = 5 so x = -6")
print("~~5 is {}".format(a))
a = ~~~5
print("~~~x = -(x+1) = -6 so x = 5")
print("~~~5 is {}".format(a))

/usr/bin/python3.8 /home/michael/PycharmProjects/DataTypes/DataType.py
5
<class ‘int’>

5.0
<class ‘float’>

65535
<class ‘int’>

4281729225
<class ‘int’>

0b11001 is binary 25
25
<class ‘int’>

I can’t believe this
<class ‘str’>

15
<class ‘int’>

15.0
<class ‘float’>

15
<class ‘str’>

(7-8j)
<class ‘complex’>
Real: 7.0 Imaginary: -8.0

~x = -(x+1) = -6 so x = 5
~5 is -6
~~x = -(x+1) = 5 so x = -6
~~5 is 5
~~~x = -(x+1) = -6 so x = 5
~~~5 is -6

Process finished with exit code 0