Download presentation
Presentation is loading. Please wait.
1
Pick a number, any number …
Random Functions Pick a number, any number …
2
Random Numbers Python has the ability to generate random numbers
We can achieve this using the randint( ) function The randint( ) function takes two arguments as the inclusive boundaries from which to choose a value from, it then returns an integer value at random
3
Random Numbers However, randint( ) is not a function that is embedded into Python’s main shell Therefore, we need to import a file called “random”, then we can call the specific function from the file
4
Random Numbers
5
Practice Define a function that recreates the guessing magic number game but this time, make the magic number randomly generated Make sure the function includes statements for whether the guess was too high or too low
6
Randomizing Statements
It would be kind of weak if we could only generate random integers and that was it We can extend these random integers into randomizing statements and other values
7
Practice Write a program of my favorite game, the one I used to lure all of you into this class … Recreate the game rock, paper, scissors on Python and have your computer play fair by random!
8
Practice See if you can recreate the rock paper scissors game to continuously run until the user does not want to play anymore OR until the user wins 5 times OR play best out of 3
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.