How to make a simple Rock, Paper, Scissor game using Python? โœŠ๐ŸคšโœŒ๏ธ

Here in this thread, I will try to make the process easier for you :)

PS - Github link for the project in the last tweet of the thread.

Thread ๐Ÿงต๐Ÿ‘‡ Image
๐—œ๐—บ๐—ฝ๐—ผ๐—ฟ๐˜๐—ถ๐—ป๐—ด ๐—น๐—ถ๐—ฏ๐—ฟ๐—ฎ๐—ฟ๐—ถ๐—ฒ๐˜€

As usual, in every project, the first step is to upload the required libraries for our project

So here we are going to import the random library of python.

Random is widely used to select randomly a choice from all the choices.

๐Ÿ”—Code Image
๐—ง๐—ฎ๐—ธ๐—ถ๐—ป๐—ด ๐—ถ๐—ป๐—ฝ๐˜‚๐˜ ๐—ณ๐—ฟ๐—ผ๐—บ ๐˜‚๐˜€๐—ฒ๐—ฟ

So the next step is to taking input from the user.

The possible choices here are rock, paper, scissors.

We will use the input function to do so.

๐Ÿ”—Code Image
๐— ๐—ฎ๐—ธ๐—ฒ ๐—ฎ ๐—น๐—ถ๐˜€๐˜ ๐—ผ๐—ณ ๐—ฎ๐—น๐—น ๐—ฝ๐—ผ๐˜€๐˜€๐—ถ๐—ฏ๐—น๐—ฒ ๐—ฐ๐—ต๐—ผ๐—ถ๐—ฐ๐—ฒ๐˜€

The next step is to make a list with all possible choices that are, rock, paper, and scissors.

๐Ÿ”—Code Image
๐—–๐—ต๐—ผ๐—ผ๐˜€๐—ฒ ๐—ฎ ๐—ฟ๐—ฎ๐—ป๐—ฑ๐—ผ๐—บ ๐—ฐ๐—ต๐—ผ๐—ถ๐—ฐ๐—ฒ ๐—ณ๐—ผ๐—ฟ ๐—ฐ๐—ผ๐—บ๐—ฝ๐˜‚๐˜๐—ฒ๐—ฟ

So the user had selected the choice and now it's the computer's turn to make a choice.

Here we will use the list made in the previous step with the random.choice function.

๐Ÿ”—Code Image
๐—ฃ๐—ฟ๐—ถ๐—ป๐˜๐—ถ๐—ป๐—ด ๐—ฏ๐—ผ๐˜๐—ต ๐˜‚๐˜€๐—ฒ๐—ฟ ๐—ฎ๐—ป๐—ฑ ๐—ฐ๐—ผ๐—บ๐—ฝ๐˜‚๐˜๐—ฒ๐—ฟ ๐—ฐ๐—ต๐—ผ๐—ถ๐—ฐ๐—ฒ

This step is completely optional, to print both user and computer choice is totally up to you.

But to make things transparent, I will recommend doing this :P

๐Ÿ”—Code Image
๐—–๐—ผ๐—บ๐—ฝ๐—ฎ๐—ฟ๐—ถ๐—ป๐—ด ๐—ฎ๐—ป๐—ฑ ๐—š๐—ฒ๐—ป๐—ฒ๐—ฟ๐—ฎ๐˜๐—ถ๐—ป๐—ด ๐˜๐—ต๐—ฒ ๐—ฟ๐—ฒ๐˜€๐˜‚๐—น๐˜

So as we all know the rules-

Tie if both same

Scissors > Paper

Paper > Rock

Rock > Scissors

So we are going to use if-else loop to compare and print the results

๐Ÿ”—Code Image
Hey all,

Hope I am able to make threads from which you are learning something new!!

Here is the link to this project GitHub link -github.com/souravjain540/โ€ฆ

If you like my content, then Retweet the first tweet of this thread :)

Until the next thread, Bye๐Ÿ˜„
Here you go to the first tweet ๐Ÿ˜

RT if you like it !!

โ€ข โ€ข โ€ข

Missing some Tweet in this thread? You can try to force a refresh
ใ€€

Keep Current with Saurav Jain

Saurav Jain Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @Sauain

10 Jul
Five Python Libraries for Machine Learning ๐Ÿ

Thread ๐Ÿงต๐Ÿ‘‡ Image
1โƒฃ ๐—ง๐—ฒ๐—ป๐˜€๐—ผ๐—ฟ๐—™๐—น๐—ผ๐˜„

It is an open-source library created by the Google Brain team.

It is very popular for high-performance numerical computation.

It has an ecosystem of tools, libraries, and community resources for building and deploying powerful ML applications. Image
2โƒฃ ๐—ž๐—ฒ๐—ฟ๐—ฎ๐˜€

Keras is a deep learning API written in Python, running on top of the machine learning platform TensorFlow.

It is a high-level neural networks API capable of running on top of TensorFlow, CNTK, or Theano.

It can run seamlessly on both CPU and GPU. Image
Read 7 tweets
6 Jul
๐—œ๐—ป๐˜๐—ฟ๐—ผ ๐˜๐—ผ ๐— ๐—ฎ๐—ฐ๐—ต๐—ถ๐—ป๐—ฒ ๐—Ÿ๐—ฒ๐—ฎ๐—ฟ๐—ป๐—ถ๐—ป๐—ด ๐Ÿ’ก

Let me introduce you to the absolute starting of Machine Learning

-What is ML?
-Its types
-Some real-world applications
๐—ช๐—ต๐—ฎ๐˜ ๐—ถ๐˜€ ๐— ๐—Ÿ? ๐Ÿ’ป

I have said this earlier too that I have done various ML courses but one of the best definition is from Andrew Ng course-

"Machine learning is the science of getting computers to act without being explicitly programmed."
๐—ง๐˜†๐—ฝ๐—ฒ๐˜€ ๐—ผ๐—ณ ๐— ๐—ฎ๐—ฐ๐—ต๐—ถ๐—ป๐—ฒ ๐—Ÿ๐—ฒ๐—ฎ๐—ฟ๐—ป๐—ถ๐—ป๐—ด

-Supervised
-Unsupervised
-Reinforcement
-Semi-supervised
Read 9 tweets
5 Jul
5 Free Courses/Sites for Beginners to learn Python ๐Ÿ’ป

๐Ÿงต๐Ÿ‘‡
1โƒฃ ๐—น๐—ฒ๐—ฎ๐—ฟ๐—ป๐—ฝ๐˜†๐˜๐—ต๐—ผ๐—ป .๐—ผ๐—ฟ๐—ด

The best way to learn python is to read docs and do the hands-on.

And this site is perfect to get started with python.

This site is supported by Datacamp.

๐Ÿ”—learnpython.org Image
2โƒฃ ๐—œ๐—ป๐—ณ๐˜†๐—ง๐—ค

This learning platform is created by one of India's topmost tech company Infosys.

If you are planning to learn python in deep, you should start with InfyTQ courses for python.

You should start with Foundation courses.

๐Ÿ”—infytq.onwingspan.com/en/page/home Image
Read 7 tweets
3 Jul
Five Basic Python Project Ideas ๐Ÿ’ก

๐Ÿงต๐Ÿ‘‡
1โƒฃ ๐—š๐˜‚๐—ฒ๐˜€๐˜€ ๐˜๐—ต๐—ฒ ๐—ก๐˜‚๐—บ๐—ฏ๐—ฒ๐—ฟ

Basic Idea -

The basic idea behind this project is that the program will ask users to guess a number between any range.

If you guess the wrong number then it will give you a hint about the number, like it is a prime number or divisible by 2
2โƒฃ ๐—ฅ๐—ผ๐—น๐—น ๐˜๐—ต๐—ฒ ๐——๐—ถ๐—ฐ๐—ฒ

Basic Idea -

Lost your Dice? No worries.

The basic idea behind this project is to make a dice using a python program.

You will use the random function of python here to generate a number between 1 & 6 (both included) and it will mimic dice for you.
Read 7 tweets
2 Jul
Five Easter Eggs in Python ๐Ÿ

๐Ÿงต๐Ÿ‘‡
1โƒฃ ๐—ฏ๐—ฟ๐—ฎ๐—ฐ๐—ฒ๐˜€

One of the most amazing feature of python is to NOT using braces rather it uses "indentation".

If you try to import braces from future in python then you will get a funny response :P

๐Ÿ“ Here is the code and output
2โƒฃ ๐—ญ๐—ฒ๐—ป ๐—ผ๐—ณ ๐—ฃ๐˜†๐˜๐—ต๐—ผ๐—ป

It is a guide to Python design principles( total = 19 )

Written by Tim Peters - American Software Developer

It is the only official easter egg stated as an easter egg in python developer guide.

๐Ÿ“ Here is the code and output
Read 7 tweets
1 Jul
Human Bias in Machine Learning !!

So letโ€™s take an example first to learn what is Human bias

๐Ÿงต๐Ÿ‘‡ Image
Close your eyes after reading this line and think what a shoe looks likeโ€ฆ

Okay stop and let see shoes
Did you picture this? Image
Read 13 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Too expensive? Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal Become our Patreon

Thank you for your support!

Follow Us on Twitter!

:(