00:01
Okay, in this problem, we're asked to write a program in python to let our user guess the results of a coin flip, heads or tails, and tell them if they are right or wrong.
00:15
And we want to use a random number generator to generate a zero or a one to represent the heads or tails.
00:25
So we'll just need to get an input from the user and turn that into a variable and use a couple of if statements to determine whether that was correct or not.
00:43
Okay, so what our program will look like? so i'll do this in a text editor and then we'll save it as a python file.
00:53
So first we'll want to import our random module.
00:58
So we'll start with import random.
01:01
And now we're going to get our input from our user.
01:04
I'm going to call that variable guess.
01:08
So we'll just take input.
01:10
And we want to eval input, since we don't want to turn it into a number, we just want to string.
01:16
So i'll say our input phrase will be here.
01:19
Let's play a game.
01:21
Guess heads.
01:22
Or tails, iterate, and so that's, so the user will enter input there.
01:35
And so that's our variable guess.
01:39
And so if guess is heads, then we want to call this, we're going to call this number, guess.
01:53
And so we're turning that string and comparing it to a value of one, zero or one.
02:03
So we'll assign heads a zero.
02:08
And then if they guess tails, i'll sign that a one.
02:22
And so i'm just going to enter two if statements here.
02:27
So this doesn't handle errors.
02:31
But the problem doesn't ask us to do that...