top of page

~Fundamental Product Programming Skills (Heads or Tails Inside Python)~

Writer's picture: ArchieArchie

Here I created a heads or tails generator using 'randint' from the random library.


I first labelled a variable called 'prediction', which would require you to input either 'h' or 't' in order for the program to detect whether you were correct or not.


The next part is another variable 'result', which uses randint. It chooses from however many numbers you have entered. The next part states that each number now corresponds to heads and tails, then prints the result of the coin toss and leaves the next part to be filled in by the next print.


The final part goes through every prediction + result variable combination and gives you the appropriate text, whether that be a correct or incorrect guess.

1 view0 comments

Recent Posts

See All

Comments


bottom of page