Answer to Question #254042 in Python for shishi

Question #254042

Write a Python application using the concepts of multithreading for a flower

shop where flowers are delivered based on order.


1
Expert's answer
2021-10-22T05:07:01-0400


SOLUTION CODE FOR ABOVE QUESTION


import threading
#A function to check whether the flowers to be delivered
# are available and confirm delivery of the requested number of flowers
def flower_delivery():
    stock_available =int(input("Enter the number of flowers remaining in the stock: "))
    stock_to_deliver =int(input("Enter the number of flowers to deliver: "))
    destination = input("Enter the destination address: ");
    if stock_available < stock_to_deliver:
        print("\nThere are no enough flowers to deliver!")

    else:
        #decreament the stock by the number of flowers to be delivered
        stock_available = stock_available - stock_to_deliver;
        print(str(stock_to_deliver) + " flowers has been delivered to " + str(destination))
        print("Remaining number of flowers in the stock is " + str(stock_available));

#Create a thread
my_flower_delivery = threading.Thread(target=flower_delivery(), args=())
#Start thread
my_flower_delivery.start()
my_flower_delivery.join()


print("\nThread execution is complete!")


SAMPLE OUTPUT OF THE PROGRAM






Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS