Coin Flip Program in Python (Heads and Tails)-Tutorial 8

Pubblicato il: 01 febbraio 2017
sul canale di: Technogrammer
11,342
46

This video will show you how to simulate a coin in Python. It uses the Python random library to generate numbers. It will use an if statement to check if the number generated should give you a head or tails! It will show you,you can change number conditions in if statement to either get a head or a tail. By doing this you can stimulate a coin flip in Python easily.

Please Subscribe an share!
Facebook:  / technogrammer  

Code used:

import random#Importing the random library.
toss=random.randint(0,1)#Toss variable's value randomly generated between the numer 0 and 1.
if toss==0:#If the varaiable is equal to 0 then:
print ("HEADS")#Heads is displayed
else:#If the Toss is not 0 then:
print("TAILS")#Tails is displayed


In questa pagina del sito puoi guardare il video online Coin Flip Program in Python (Heads and Tails)-Tutorial 8 della durata di ore minuti seconda in buona qualità , che l'utente ha caricato Technogrammer 01 febbraio 2017, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 11,342 volte e gli è piaciuto 46 spettatori. Buona visione!