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

Veröffentlicht am: 01 Februar 2017
auf dem Kanal: 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


Auf dieser Seite können Sie das Online-Video Coin Flip Program in Python (Heads and Tails)-Tutorial 8 mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer Technogrammer 01 Februar 2017 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 11,342 Mal angesehen und es wurde von 46 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!