Python | os.cpu_count() method

OS module in Python provides functions for interacting with the operating system. OS comes under Python’s standard utility modules. This module provides a portable way of using operating system dependent functionality.

os.cpu_count() method in Python is used to get the number of CPUs in the system. This method returns None if number of CPUs in the system is undetermined.

Syntax: os.cpu_count()

Parameter: No parameter is required.

Return Type: This method returns an integer value which denotes the number of CPUs in the system. None is returned if the number of CPUs is undeterminded.

Code: Use of os.cpu_count() method to get the number of CPUs in the system





# Python program to explain os.cpu_count() method  
# importing os module 
import os
# Get the number of CPUs
# in the system using
# os.cpu_count() method
cpuCount = os.cpu_count()
# Print the number of
# CPUs in the system
print("Number of CPUs in the system:", cpuCount)



Number of CPUs in the system: 4
My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using or mail your article to See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

Article Tags :

Be the First to upvote.

Please write to us at to report any issue with the above content.