-
-
Save mastro35/c956f9d5ee80e31155799aa14d7d99f0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
import datetime | |
def get_candy_price(candy_id): | |
# let's use a sleep to simulate the time your function spends trying to connect to | |
# the web service, 5 seconds will be enough. | |
time.sleep(5) | |
# let's pretend that the price returned by the web service is $1 for candies with a | |
# odd candy_id and $1,5 for candies with a even candy_id | |
price = 1.5 if candy_id % 2 == 0 else 1 | |
return (datetime.datetime.now().strftime("%c"), price) | |
# now, let's simulate 20 customers in your show. | |
# They are asking for candy with id 2 and candy with id 3... | |
for i in range(0,20): | |
print(get_candy_price(2)) | |
print(get_candy_price(3)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment