Python Program To Find Size Of Data Types

Python Program To Find Size Of Data Types

Write Python code to find the size of data types

# WAP to Find the size of vari Datatypes

import sys

print('size of integer :--> ', sys.getsizeof(int()))
print('size of float:--> ', sys.getsizeof(float()))
print('size of string :--> ', sys.getsizeof(str()))
print('size of list :--> ', sys.getsizeof(list()))
print('size of set :--> ', sys.getsizeof(set()))
print('size of tuple :--> ', sys.getsizeof(tuple()))
print('size of dictitonary :--> ', sys.getsizeof(dict()))

Output:

size of integer :--> 24
size of float :--> 24
size of string :--> 49
size of list :--> 56
size of set :--> 216
size of tuple :--> 40
size of dictionary :--> 232