Python: Display some information about the OS where the script is running
Python Basic - 1: Exercise-10 with Solution
Write a Python program to display some information about the OS where the script is running.
Sample Solution:
Python Code:
import platform as pl
os_profile = [
'architecture',
'linux_distribution',
'mac_ver',
'machine',
'node',
'platform',
'processor',
'python_build',
'python_compiler',
'python_version',
'release',
'system',
'uname',
'version',
]
for key in os_profile:
if hasattr(pl, key):
print(key + ": " + str(getattr(pl, key)()))
Sample Output:
architecture: ('64bit', 'ELF') linux_distribution: ('Ubuntu', '16.04', 'xenial') mac_ver: ('', ('', '', ''), '') machine: x86_64 node: 9a911676793b platform: Linux-4.4.0-57-generic-x86_64-with-Ubuntu-16.04-xenial processor: x86_64 python_build: ('default', 'Nov 17 2016 17:05:23') python_compiler: GCC 5.4.0 20160609 python_version: 3.5.2 release: 4.4.0-57-generic system: Linux uname: uname_result(system='Linux', node='9a911676793b', release='4.4.0-57-generic', version='#78-Ubuntu SMP Fri Dec 9 23:50:32 UTC 2016', machine='x86_64', processor='x86_64') version: #78-Ubuntu SMP Fri Dec 9 23:50:32 UTC 2016
Flowchart:

Python Code Editor :
Have another way to solve this solution? Contribute your code (and comments) through Disqus.
Previous: Write a Python program to get a list of locally installed Python modules.
Next: Write a Python program to check the sum of three elements (each from an array) from three arrays is equal to a target value. Print all those three-element combinations.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.
Python: Tips of the Day
Unzipping:
name = 'abcdef' suffix = [1,2,3,4,5,6] result = zip(name, suffix) --> returns (a,1),(b,2),(c,3),(d,4),(e,5),(f,6) unzipped = zip(*result)
- Weekly Trends
- Python Interview Questions and Answers: Comprehensive Guide
- Scala Exercises, Practice, Solution
- Kotlin Exercises practice with solution
- MongoDB Exercises, Practice, Solution
- SQL Exercises, Practice, Solution - JOINS
- Java Basic Programming Exercises
- SQL Subqueries
- Adventureworks Database Exercises
- C# Sharp Basic Exercises
- SQL COUNT() with distinct
- JavaScript String Exercises
- JavaScript HTML Form Validation
- Java Collection Exercises
- SQL COUNT() function
- SQL Inner Join
We are closing our Disqus commenting system for some maintenanace issues. You may write to us at reach[at]yahoo[dot]com or visit us at Facebook