Write a python program to check memory sizes of list ,set ,tuple

Write a python program to check memory sizes of list ,set ,tuple

Program
import sys
def myfun():
    a = ['red', 'green', 'blue', 'orange']
    b = {'red', 'green', 'blue', 'orange'}
    c =('red', 'green', 'blue', 'orange')
    print("The memory size of a list is : ",sys.getsizeof(a))
    print("The memory size of a set is : ",sys.getsizeof(b))
    print("The memory size of a tuple is : ",sys.getsizeof(c))
                 
if __name__=="__main__":
    myfun()


Output:

The memory size of a list is : 120
The memory size of a set is : 216
The memory size of a tuple is : 72



More Questions


48 . Write a python program to check memory sizes of list ,set ,tuple
49 . How do you confirm if an object is iterable using code?
50 . Write a python program to sort list with sorted & lambda
51 . Write a python program to access news using python
52 . Write a python program to print lowercase names
53 . Write a python program to Find Index Using Enumerate
54 . Write a python program to checking if a string is empty or not ?
55 . Write a python program to merge nested lists ?
56 . Write a python program to Checking if a File Exists or Not ?
57 . Write a python program to convert uppercase strings and we want to convert them into lowercase strings and remove duplicates ?
58 . Write a python program to display list of numbers and we want to return all the numbers from the list that are divisible by 2 and remove duplicates at the same time.



For latest job updates join Telegram Channel: https://t.me/sateeshm