flip coin code example
Example 1: coinflip
import random
random.choice('Heads', 'Tails')
Example 2: Flip a coin
var rand = ['Heads', 'Tails'];
var randOption = rand[Math.floor(Math.random() * rand.length)];
console.log(randOption);
Example 3: coin flip
#Ruby
def coin_flip(num_of_flips = 1)
array = ["heads","tails"]
num_of_flips.times do
puts out_come = array[rand(0..1)]
end
end
coin_flip() # You can set the number of times you flip it ;)
Example 4: coin flip
using System;
Random rnd = new Random();
string Answer = "Head";
if (rnd.Next(0,2) == 1)
{
Answer = "Tails" ;
}