Making a Rock-Paper-Scissors game
- 라임 샹큼
- Feb 23
- 2 min read
What made me do this?
I remember being moderately confused when we entered the random module session in class. First of all there were a few types of random modules I needed to be wary of and they also had different functions and rules. Secondly, I didn't put that much time into understanding it fully..
random.randint
random.randrange
random.shuffle
random.choice
.
.
+differentiating from range()
Naturally, I wanted to get to know it better and decided to put the time in to understand it better.
What better way to explore random modules than making a rock-paper-scissors game?
file:///Users/gaeunlee/PycharmProjects/100%20Days%20of%20Code%20-%20The%20Complete%20Python%20Pro%20Bootcamp/exportToHTML/task.py.html
This is the code I wrote for the 'game', more like an interaction.
It's not very complex but making myself commit to a project proved to be more useful than cramming facts into my head and memorizing the characteristics of the modules.
Other things I learned
Random modules were provided by Python because of the complexity of having to devise a code in its entirety by yourself. As it is an existing thing already made by somebody, this supplies that I too can make a module. This is exactly what I tested out.
Making my_module
Although I have little knowledge still about modules as a whole, it was interesting to know that modules could be made and implemented later on to make the whole code shorter or more efficient.
Overview of what I learned
I can make my own modules to make code more succinct and efficient
random modules
random.randint(a,b)
picks an integer that is between a and b(including both)
random.choice(list)
chooses element from list
random.random()
picks floats from 0.0(including) to 1.0(excluding)
random.unifom(a,b)
picks floats from a(including) to b(excluding)
*random.random and random.uniform diffferent because of range of numbers.
to use random.random like random.uniform, multiply required number.
Comments