Computer Science, asked by namrata6969, 1 year ago

how is process different from a program in python​

Answers

Answered by parzival2005
1

Multiprocessing in Python

In Python, the multiprocessingmodule includes a very simple and intuitive API for dividing work between multiple processes.

Let us consider a simple example using multiprocessing module:

# importing the multiprocessing module

import multiprocessing

  

def print_cube(num):

    """

    function to print cube of given num

    """

    print("Cube: {}".format(num * num * num))

  

def print_square(num):

    """

    function to print square of given num

    """

    print("Square: {}".format(num * num))

  

if __name__ == "__main__":

    # creating processes

    p1 = multiprocessing.Process(target=print_square, args=(10, ))

    p2 = multiprocessing.Process(target=print_cube, args=(10, ))

  

    # starting process 1

    p1.start()

    # starting process 2

    p2.start()

  

    # wait until process 1 is finished

    p1.join()

    # wait until process 2 is finished

    p2.join()

  

    # both processes finished

    print("Done!")

Square: 100 Cube: 1000 Done!

Answered by arshad49
1

Answer:

Python examples on simple mathematical problems

Python Program to add two numbers.

Python program to check if a number is prime or not.

Python Program to check even or odd number.

Python program to convert Decimal to binary.

Python program to find factorial of a number.

Python program to add two binary numbers

Explanation:

The process of converting the value of one data type (integer, string, float, etc.) to another is called type conversion. Python has two types of type conversion...

In detail plz. contact me 6204099229 ...

Your last digits of your contact. ...........9611 ????

Similar questions