Wednesday, July 3, 2024
HomeLanguagesPythonPython | os.cpu_count() method

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 undetermined.

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)


Output:

Number of CPUs in the system: 4
Dominic Rubhabha Wardslaus
Dominic Rubhabha Wardslaushttps://neveropen.dev
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments