Saurav Jain (Open Source + Communities) Profile picture
Jul 9, 2021 โ€ข 9 tweets โ€ข 3 min read โ€ข Read on X
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 (Open Source + Communities)

Saurav Jain (Open Source + Communities) 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

Feb 25, 2023
How to write beautiful Python code? ๐Ÿ’ฏ

Learn about PEP 8 Convention ๐Ÿงต๐Ÿ‘‡
๐—ฃ๐—˜๐—ฃ-๐Ÿด

-Want to write an "Eye-pleasing" Python code ๐Ÿ ๐Ÿ‘€?

-PEP is a thing you MUST know about while learning or writing a python code

-Python Enhancement Proposal

-Basically a guide to "๐—›๐—ผ๐˜„ ๐˜๐—ผ ๐˜„๐—ฟ๐—ถ๐˜๐—ฒ ๐—ฎ ๐—ฏ๐—ฒ๐—ฎ๐˜‚๐˜๐—ถ๐—ณ๐˜‚๐—น ๐—ฝ๐˜†๐˜๐—ต๐—ผ๐—ป ๐—ฐ๐—ผ๐—ฑ๐—ฒ?"
We all know that besides having logic and coding in any programming language, there is an important factor that is "coding style."

-How are we writing comments?
-How are we giving spaces?
-How to import libraries?
-etc

These things are very important to writing beautiful code!
Read 12 tweets
Feb 24, 2023
Six websites that will keep you updated about the latest trends in Python ๐Ÿ

Thread ๐Ÿงต๐Ÿ‘‡
1. @realpython

The best site for Python. It helped me a lot personally in the learning process.

๐Ÿ”— realpython.com
2. Python Blogs

A dedicated platform for learners and professionals for Python

๐Ÿ”— pythonblogs.com
Read 8 tweets
Feb 23, 2023
Five FREE Certifications which you can learn and add to your Resume ๐Ÿ˜‰๐Ÿ’ฏ

- Python
- Chatbot Development
- Machine Learning
- NLP

Thread ๐Ÿงต๐Ÿ‘‡
1. Data Flair

20+ Hours Course to learn Python Step by Step with a Certificate on the completion

๐Ÿ”— data-flair.training/python-course/
2. Programming Essentials in Python ( CISCO )

This course is a great place to learn Python โ€“ no prior programming knowledge is required. Completing the course earns you a Statement of Achievement.

๐Ÿ”— netacad.com/courses/prograโ€ฆ
Read 7 tweets
Nov 21, 2022
Programming is interesting if you are learning it from good resources.

5 courses that helped me learn programming concepts. ๐Ÿงต
1. CS50 by Harvard

Build strong basics of Computer Science and fundamentals.

2. @freeCodeCamp

Basics of programming by freecodecamp.

Read 7 tweets
Nov 15, 2022
Learning Classification in Supervised Machine Learning from Scratch ๐Ÿงต๐Ÿ‘‡
Classification, by name, means to classify things into sub-categories.

For example, our computers can differentiate between red and blue, cat and dog, pencil and pen, and so on.
Classification is the problem of identifying to which of a set of categories (subpopulations), a new observation belongs, based on a training set of data containing observations and whose categories membership is known.
Read 8 tweets
Nov 2, 2022
Five FREE courses for Machine Learning, Artificial Intelligence, NLP, Web Development, and Computer Programming from world-class universities like Stanford, MIT, Harvard, etc. ๐Ÿงต
1. Machine Learning by Stanford University

This is a playlist of all the lectures taken by Prof. Andrew Ng in Stanford's ML course.

๐Ÿ”—
2. Harvard CS 50

Learn the basics of computer science from Harvard University. This is CS50, an introduction to the intellectual enterprises of computer science and the art of programming.

๐Ÿ”—
Read 7 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

Don't want to be a Premium member but still want to support us?

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

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us!

:(