Python - Random Program

Random program:

# comments 

from random import random #we are importing random from random module

def flip_coin():

r = random() #assigning the random value to r

if r > 0.5: #if value is greater than 0.5 then 

return "Heads"

else:

return "tails"

print(flip_coin()) # print the output . we need to call the function , hence flip_coin() with parenthesis.


output:






Comments

Popular posts from this blog

Journey Begins for Network Automation and or Devops Profile

Job Offers or Interview Calls and Feedback while searching for network automation roles