Project 1: Coin Toss - Python Tutorials For Beginners #4
Let’s Create Something Amazing With Python!
In this blog, we’ll be learning how to create a Python program to make a simple
coin toss project. This project is perfect for beginners. Today, We all learn
about the practical application of concepts in Python.
This program will allow the computer to randomly choose one of two outcomes and
display it.
Concepts Used In This Project
(1) Variables
(2) Datatypes
(3) Random Module
(4) Print Function
We import the Random module to use its function. The module is a pre-defined code in programming. Here, We use random.choice() function to choose one element in the list.
1# Project 1: Coin Toss In Python
2import random
Now, I create a list called List, Which contains Heads and Tails.
1List = ["Heads", "Talis"]
Here, I use the print function to display randomly chosen value from the list by Python.
1print(random.choice(List))
Whole Code
1# Project 1: Coin Toss In Python
2import random
3List = ["Heads", "Talis"]
4print(random.choice(List))