Python - Coin Toss Coding Tutorial

preview_player
Показать описание
Learn how to code a coin toss app using Python.

~ CODE ~
import random

coin = ["Heads","Tails"]

selection = input("Heads or Tails: ")

if selection == toss:
print("You win! The coin landed on " + toss)
else:
print("You lose! The coin landed on " + toss)
Рекомендации по теме
Комментарии
Автор

Modify the coin flip program as discuss on the module. The program should ask a user input either 0 (tails) or 1 (heads). Then the program will draw a coin flip. The program will declare the user a winner if the result of the coin flip is equal to the user input. If the user enters a value outside the given choices, it will display invalid choice.

ianceasarurbano
Автор

u just got me a 5 at the end of the year from IT classes

marcinkoodziejczak
Автор

“It’s basically just another line of code written by another smart person” - Geek tutorials

qwertico
Автор

Hey man, can you loop this game? for example, after the program tells you if you won or lost can you write something in the code so it allows you to play it again without restarting?

snipek
Автор

Is it possible you can convert this to scratch?

lemontiger
Автор

How coin flips are meant to be

import random
coin = ["Heads", "Tails"]
toss = random.choice(coin)
selection = input("Heads or Tails: ")
if selection == toss:
print("You win! The coin landed on " + toss)
else:
print("You lose! The coin landed on " + toss)


How coin flips feel
selection = input("Heads or Tails: ")
if selection = "Heads":
print("You lose! The coin landed on tails!)
else:
print("You lose! The coin landed on heads!)

lamemelord
Автор

I'm a creator like u but in Hindi ( mother tongue of Indians)

spyler