Quantcast
Channel: Rock paper scissors - Code Review Stack Exchange
Browsing latest articles
Browse All 5 View Live

Answer by 200_success for Rock paper scissors

Your program is adequate, but it doesn't "scale". Each player can choose from 3 moves; of those 9 possibilities, the 3 ties can be handled in common, for a total of 7 code branches. Handling all those...

View Article



Answer by theodox for Rock paper scissors

Rather than making the game a class, consider making the choices a class. This makes it easy to define the behaviors:import sysfrom random import choiceclass RPS(object): def __init__(self, name, rank,...

View Article

Answer by Stuart for Rock paper scissors

You can reduce if...elif... by noting that there are only three possible outcomes and finding a simple way to describe the conditions for each outcome. You can store the outcome (win, lose, draw) in a...

View Article

Answer by Hugh Bothwell for Rock paper scissors

There is no overall structure to this program, just an undifferentiated mass of code.There is a lot of redundancy to the 'if... elif... elif...' structure which could be pulled out into a function;...

View Article

Rock paper scissors

I've started learning Python recently and I wanted to test myself. So, can you tell me how many I would get out of 10 and how I could improve my future coding?import randomimport timeprint('Welcome to...

View Article

Browsing latest articles
Browse All 5 View Live




Latest Images