79094606

Date: 2024-10-16 14:52:39
Score: 2
Natty:
Report link

Use Python's struct module. It calculates and prints the size of primitive data types in bytes.

struct.calcsize() function can be used to determine the memory size of binary data.

import struct

print(struct.calcsize("i")) # integer.........returns 4

print(struct.calcsize("f")) # float........returns 4

print(struct.calcsize("d")) # double........returns 8

print(struct.calcsize("c")) # character......returns 1

print(struct.calcsize("h")) # short......returns 2

print(struct.calcsize("l")) # long.......returns 4

print(struct.calcsize("q")) # long long....returns 8

print(struct.calcsize("?")) # boolean......returns 1

Reasons:
  • Long answer (-0.5):
  • No code block (0.5):
  • Contains question mark (0.5):
  • Filler text (0.5): .........
  • Filler text (0): ........
  • Filler text (0): ........
  • Low reputation (1):
Posted by: Kotipalli Mounika