write a simple program that displays 4 python primitive data types sizes in bytes run the program on a command prompt CMD. attach a photo of the source file in the text editior and the excutable on CMD
ex;
the size of int in bytes is ...
the size of floot in bytes is ...
the size of string in bytes is ...
the size of char in bytes is ....
Python :
# importing sys
import sys
# initializing int,float, char and string variables
i=0
f=0.0
c='c'
s='string'
#printing the sizes of int,float, char and string
print("the size of int in bytes
is",sys.getsizeof(i))
print("the size of float in bytes is" ,sys.getsizeof(f))
print("the size of string in bytes is" ,sys.getsizeof(s))
print("the size of char in bytes is" ,sys.getsizeof(c))
Output :
Python have int, float and string datatypes. character is nothing but a string of length 1.
Get Answers For Free
Most questions answered within 1 hours.