Python: Test whether the system is a big-endian platform or little-endian platform
Python Basic: Exercise-77 with Solution
Write a Python program to test whether the system is a big-endian platform or little-endian platform.
sys.byteorder: An indicator of the native byte order. This will have the value 'big' on big-endian (most-significant byte first) platforms, and 'little' on little-endian (least-significant byte first) platforms.
import sys print() if sys.byteorder == "little": #intel, alpha print("Little-endian platform.") else: #motorola, sparc print("Big-endian platform.") print()
Python Code Editor:
Have another way to solve this solution? Contribute your code (and comments) through Disqus.
Previous: Write a Python program to get the command-line arguments (name of the script, the number of arguments, arguments) passed to a script.
Next: Write a Python program to find the available built-in modules.
What is the difficulty level of this exercise?
Test your Python skills with w3resource's quiz
Python: Tips of the Day
try: foo() except Exception: print("Exception occured") else: print("Exception didnt occur") finally: print("Always gets here")
- New Content published on w3resource:
- Scala Programming Exercises, Practice, Solution
- Python Itertools exercises
- Python Numpy exercises
- Python GeoPy Package exercises
- Python Pandas exercises
- Python nltk exercises
- Python BeautifulSoup exercises
- Form Template
- Composer - PHP Package Manager
- PHPUnit - PHP Testing
- Laravel - PHP Framework