πŸ’ object oriented - Simple Blackjack game in Python - Code Review Stack Exchange

Most Liked Casino Bonuses in the last 7 days πŸ’°

Filter:
Sort:
CODE5637
Bonus:
Free Spins
Players:
All
WR:
60 xB
Max cash out:
$ 200

Let's look at your Card class. class Card: def __init__(self): pass def card_value(​self): pass card_face = ['Ace','2','3','4','5','6','7','8','9','10','J','Q'.


Enjoy!
Valid for casinos
Visits
Likes
Dislikes
Comments
pygame blackjack game

CODE5637
Bonus:
Free Spins
Players:
All
WR:
60 xB
Max cash out:
$ 200

I will assume some basic familiarity with the game of Blackjack, but here is a quick refresher for how the game is played: Players make their.


Enjoy!
Valid for casinos
Visits
Likes
Dislikes
Comments
pygame blackjack game

CODE5637
Bonus:
Free Spins
Players:
All
WR:
60 xB
Max cash out:
$ 200

Blackjack. This is a GUI version of the game blackjack, written in Python and Pygame. It is easy to play, and can be very fast-paced.


Enjoy!
Valid for casinos
Visits
Likes
Dislikes
Comments
pygame blackjack game

πŸ’

Software - MORE
CODE5637
Bonus:
Free Spins
Players:
All
WR:
60 xB
Max cash out:
$ 200

Blackjack. This is a GUI version of the game blackjack, written in Python and Pygame. It is easy to play, and can be very fast-paced.


Enjoy!
Valid for casinos
Visits
Likes
Dislikes
Comments
pygame blackjack game

πŸ’

Software - MORE
CODE5637
Bonus:
Free Spins
Players:
All
WR:
60 xB
Max cash out:
$ 200

I will assume some basic familiarity with the game of Blackjack, but here is a quick refresher for how the game is played: Players make their.


Enjoy!
Valid for casinos
Visits
Likes
Dislikes
Comments
pygame blackjack game

πŸ’

Software - MORE
CODE5637
Bonus:
Free Spins
Players:
All
WR:
60 xB
Max cash out:
$ 200

Your code looks nice, well documented and is split into small functions. Also, you'​ve used the if __name__ == "__main__" which is a nice touch.


Enjoy!
Valid for casinos
Visits
Likes
Dislikes
Comments
pygame blackjack game

πŸ’

Software - MORE
CODE5637
Bonus:
Free Spins
Players:
All
WR:
60 xB
Max cash out:
$ 200

First try at a python game. Contribute to ServePeak/Blackjack-Python development by creating an account on GitHub.


Enjoy!
Valid for casinos
Visits
Likes
Dislikes
Comments
pygame blackjack game

πŸ’

Software - MORE
CODE5637
Bonus:
Free Spins
Players:
All
WR:
60 xB
Max cash out:
$ 200

umor-russkie.online β€Ί watch.


Enjoy!
Valid for casinos
Visits
Likes
Dislikes
Comments
pygame blackjack game

πŸ’

Software - MORE
CODE5637
Bonus:
Free Spins
Players:
All
WR:
60 xB
Max cash out:
$ 200

Your code looks nice, well documented and is split into small functions. Also, you'​ve used the if __name__ == "__main__" which is a nice touch.


Enjoy!
Valid for casinos
Visits
Likes
Dislikes
Comments
pygame blackjack game

πŸ’

Software - MORE
CODE5637
Bonus:
Free Spins
Players:
All
WR:
60 xB
Max cash out:
$ 200

umor-russkie.online β€Ί watch.


Enjoy!
Valid for casinos
Visits
Likes
Dislikes
Comments
pygame blackjack game

Loops Here you make a variable at the start, but you can just execute the loop and then set ans. Post as a guest Name. For example maybe you want to use card as a variable somewhere more appropriate. Here again, you'll find tools to help you such as pydocstyle formerly known as pep Also, for more comprehensive documentation, you may want to go further than bland text and use the reStructuredText markup. Featured on Meta. In particular, the bust and blackjack functions should have an explicit return None at the end even though it should be even better to use return False. Here is my version 2: Program simulate Blackjack game. Podcast New tools for new times. If you don't would you downvote an answer because it uses one? It could be nicer to ask again if the user gives an invalid answer rather than taking a default decision an empty input could be considered as valid if the prompts says so explicitely. SylvainD SylvainD 28k 1 1 gold badge 41 41 silver badges 90 90 bronze badges. It deals with various aspects of the code style: naming conventions, indentation convention, etc. Asked 2 years, 3 months ago. This is highly recommended reading. Changing this and documenting it properly, you'd have something like: def bust hand : """Return True if the hand value is bigger than 21, False otherwise. Sign up to join this community. This is for readability and will save you some variable names. Your code looks nice, well documented and is split into small functions. Simple program simulates Blackjack game. Sign up or log in Sign up using Google. You'll find various tools to try to check whether your code is PEP 8 compliant and if is it not, to try and fix this: pycodestyle package formerly known as pep8 to check you code pep8online to check your code with an online tool autopep8 package to fix your code automatically Also, this is also checked by various linters: pylint , pyflakes , flake8 , etc. If any return statement returns an expression, any return statements where no value is returned should explicitly state this as return None, and an explicit return statement should be present at the end of the function if reachable. Either all return statements in a function should return an expression, or none of them should. It's small but id try to be a bit more descriptive with your function names, that is most functions have a verb style to them. Question feed.{/INSERTKEYS}{/PARAGRAPH} As far as I can understand, whenever a new card is given, you just pick a value at random. Also, another recent part of PEP 8 is not followed by your code: Be consistent in return statements. Also, there are conventions for Python docstrings described in PEP As far as I can tell, it is not followed as strongly by the community as PEP 8 can be but it is still a reference worth reading. There is an official standard Python style guide called PEP 8. The best answers are voted up and rise to the top. PEP give more details about this but it is not something I am familiar with. In your case, writing docstring could help you by forcing you to find how to describe your functions, their inputs, they return valuem etc. Victor Nguyen Bao. I am new to programming, and I am doing some homework to get more hands on coding experience. It looks like we could be adding a return None at the end that does not return the function behavior. All face cards count as 10 points," print "aces count as 1 or 11, and all other cards count their numeric value. Active Oldest Votes. I'll try to continue this later Bug in the distribution of the cards As far as I can understand, whenever a new card is given, you just pick a value at random. It gives guidelines to help writing code that is both readable and consistent. I have written a blackjack game in Python 3 and would like a code review of any and all of my code. The Overflow Blog. You can see it as special form of documentation found only at the beginning of definitions and that is easy to access which is not the case for comments like this for instance with help. Active 2 years, 3 months ago. It is best not to edit your question once answers have been given. You'll find various tools to try to check whether your code is PEP 8 compliant and if is it not, to try and fix this:. Let's update the modal for new askers. Structured blackjack game in Python 3 Ask Question. Email Required, but never shown. Changing this and documenting it properly, you'd have something like:. We're switching to CommonMark. Viewed 4k times. Condition True, if user want to Hit. Then you'll get a behaviour which is not quite the one you'd have with a deck of cards. {PARAGRAPH}{INSERTKEYS}Code Review Stack Exchange is a question and answer site for peer programmer code reviews. Here you make a variable at the start, but you can just execute the loop and then set ans. Phrancis: A final review of a good member. If you do so, it is a good idea to define a new functions wrapping input to handle user interactions and validation of input retrieved instead of having your input validation logic and your game logic mixed up. What posts should be escalated to staff using [status-review], and how do I…. Indeed, in your case, events are independent. With a deck of cards, the probability of getting a given card depends on previous cards given for an extreme example, once you've drawn 4 aces, the probability to pick a fifth is zero. Why the developers who use Rust love it so much. Sign up using Facebook. Related 2. Also, this is also checked by various linters: pylint , pyflakes , flake8 , etc. Then, a few details could be improved to make the interactions with the user clearer. The same comments applies to blackjack. Home Questions Tags Users Unanswered. It only takes a minute to sign up. However, if we were to think about what the function returns, True or None seems a bit un-natural; True or False makes more sense. Tony Tony 1 1 silver badge 9 9 bronze badges. What you could do is to open a new question with the new updated code it is best to wait for more answers on this question first. Sign up using Email and Password. Be consistent in return statements. Let's try to see if the code can be improved anyway : Style There is an official standard Python style guide called PEP 8. This will also allow you to cleanup your exit condition:. Hot Network Questions. Also, as suggested in the other excellent answer, the names of the functions could be improved to be more explicit. The Python community tries to follow these guidelines, more or less strictly a key aspect of PEP 8 is that it provides guidelines and not strict rules to follow blindly.