w3resource

Python: Determine if the python shell is executing in 32bit or 64bit mode on operating system

Python Basic: Exercise-143 with Solution

Write a Python program to determine if the Python shell is executing in 32-bit or 64-bit mode on the operating system.

Sample Solution-1:

Python Code:

# Import the 'struct' module for working with C-style data in Python.
import struct
# Use 'struct.calcsize("P")' to calculate the size of a C 'void *' pointer in bytes and 'struct.calcsize("P") * 8' to convert it to bits.

# Print the result, which represents the size of a C 'void *' pointer in bits.
print(struct.calcsize("P") * 8)

Sample Output:

64 

Flowchart:

Flowchart: Determine if the python shell is executing in 32bit or 64bit mode on operating system.

Python Code Editor:

 

Previous: Write a Python program to check if every consecutive sequence of zeroes is followed by a consecutive sequence of ones of same length in a given string. Return True/False.
Next: Write a Python program to check whether variable is of integer or string.

What is the difficulty level of this exercise?

Test your Programming skills with w3resource's quiz.



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://w3resource.com/python-exercises/python-basic-exercise-143.php