Github Blackjack Python

 admin

Welecome to Python Portfolio of Rajesh!

  1. Opencv Python Github
  2. Blackjack Game Python Github
  3. Python Github Api
  4. Github Python Projects

1. Drawing Circle with squares

First of all, I'm sorry I know that this question has been answered already but I wasn't able to get my answer from that. I've been using python for almost 2 years and can say that I'm pretty good at it and improving day by day. I want to make some make money off python even if it's a small amount. SmartBody is available for download for Windows, Linux and OSX users. SmartBody can also be used on Android and iOS platforms. SmartBody is a character animation platform that provides the following capabilities in real time:. Locomotion (walk, jog, run, turn, strafe, jump, etc.). Steering - avoiding obstacles and moving objects. Object manipulation - reach, grasp, touch, pick up objects.

Using turtle library

Click here to see the code.

Screenshot of the program output ->

2. Drawing Flower using Rhombus

Using turtle library

Screenshot ->

3. Find Monthly Pay

Using approximation algorithm calculating how much one has to pay each month given initial loan amount and annual compound interest rate to pay off complete amount in 1 year.

Here is the code for this program.

4. Guess the Number by Computer

Blackjack game python github

In this game computer asks us to select any secret number in mind between 1 to 100. Computer is allowed only 7 guesses and yet it always wins. Player has to type 'h', 'l' or 'c' according to the guessed value is high, low or correct.

Code of the program.

Here is the screen shot of program when I choose 21 as my secret number ->

5. Guess the Number by Human

This is a complementary version of the above game where computer chooses a secret number and human player has to guess. If range is 0-100 then 7 guesses allowed whereas 10 guesses allowed for range 0-1000. This program uses simplegui library. You can run this program at http://www.codeskulptor.org/.

Here is the code.

Screenshot of the program when computer chooses 64 secret number ->

6. Hangman game (Text Version)

This is a classic game of guessing word letter by letter within some finite chances.

Here is the code.

Screenshot of the game ->

7. Longest Alphabetical Sequence

This program takes input as any one string and finds longest alphabetical sequence.

Here is the code.

8. Movie Trailers Showcase

This program creates a webpage showcasing my favorite movie trailers in a browser.

Here is the code.

Screenshot of the webpage generated when program is executed->

9. Classic Arcade Pong game

This is the classic arcade game Pong. This game can be played here http://www.codeskulptor.org/#user40_DWG0hswoqwI7kJQ.py.

Here is the code.

Screenshot of the game->

10. Profanity Editor

Given any text file this program checks whether there are any curse words in the file or not. If any curse word is found then program returns the alert message.

Code can be found here.

11. Rock-paper-scissors-lizard-Spock game

This is the Big Bang Theory version of the Rock-Paper-Scissors game.

Opencv Python Github

Here is the code.

Screenshot of the program->

12. Send text to any cellphone

This python program sends the text to cellphone. It used TwilioRestClient library for sending the message. You have to have account on the twilio for the program to work.

Code for the program.

13. Stopwatch: The Game

In this game you will find digital watch where you have to click stop button exactly when second is complete. It used simplegui library.

Here is the code.

Screenshot of the game while playing->

14. Word Game

This game is a lot like Scrabble or Words With Friends, if you've played those. Letters are dealt to players, who then construct one or more words out of their letters. Each valid word receives a score, based on the length of the word and the letters in that word.

Here is the code.

Screenshot of the game while playing->

15. Edx Exam Programs

  • Write a Python function that returns a list of keys in aDict with the value target. The list of keys you return should be sorted in increasing order. The keys and values in aDict are both integers. (If aDict does not contain the value target, you should return an empty list.)This function takes in a dictionary and an integer and returns a list.Code
  • Write a Python function that returns the sublist of strings in aList that contain fewer than 4 characters. For example, if aList = ['apple', 'cat', 'dog', 'banana'], your function should return: ['cat', 'dog']This function takes in a list of strings and returns a list of strings. Your function should not modify aList.Code
  • Write a simple procedure, myLog(x, b), that computes the logarithm of a number x relative to a base b. For example, if x = 16 and b = 2, then the result is 4 - because 2^4=16. If x = 15 and b = 3, then the result is 2 - because 3^2 is the largest power of 3 less than 15.In other words, myLog should return the largest power of b such that b to that power is still less than or equal to x.x and b are both positive integers; b is an integer greater than or equal to 2. Your function should return an integer answer.Code
  • Assumes L is a list of strings. Assume function f is already defined for you and it maps a string to a Boolean. Mutates L such that it contains all of the strings, s, originally in L such that f(s) returns True, and no other elements Returns the length of L after mutation.Code
  • Write a recursive Python function, given a non-negative integer N, to calculate and return the sum of its digits.Hint: Mod (%) by 10 gives you the rightmost digit (126 % 10 is 6), while doing integer division by 10 removes the rightmost digit (126 / 10 is 12).This function has to be recursive; you may not use loops!This function takes in one integer and returns one integer.Code

16. Memory Game

Memory is a card game in which the player deals out a set of cards face down. In Memory, a turn (or a move) consists of the player flipping over two cards. If they match, the player leaves them face up. If they don't match, the player flips the cards back face down. The goal of Memory is to end up with all of the cards flipped face up in the minimum number of turns. A Memory deck consists of eight pairs of matching cards.This program uses simplegui library. You can run this program at http://www.codeskulptor.org/.

Here is the code.

Screenshot of the game at start->

In the middle while playing->

After finishing a game->

17. Caesar Cipher - Cryptography

In this problem, we will use a variant of the standard Caesar cipher where we will treat upper and lower case letters separately, so upper case letters will always be mapped to upper case letters, and lower case letters will always be mapped to lower case letters. Thus, if 'a' maps to 'c', 'A' will map to 'C'. Characters such as the space character, commas, periods, exclamation points, etc will not be encrypted by this cipher - basically, all the characters within string.punctuation, plus the space (' ') and all numerical characters (0 - 9).

Here is the code.

Game

Screenshot of the program in action->

18. BlackJack Game

Blackjack is a simple, popular card game that is played in many casinos. Cards in Blackjack have the following values: an ace may be valued as either 1 or 11 (player's choice), face cards (kings, queens and jacks) are valued at 10 and the value of the remaining cards corresponds to their number. During a round of Blackjack, the players plays against a dealer with the goal of building a hand (a collection of cards) whose cards have a total value that is higher than the value of the dealer's hand, but not over 21. (A round of Blackjack is also sometimes referred to as a hand.)

Here is the code.

Screenshot of the program in action->

19. Asteroids Game

This is the updated version of Asteroids game which is an arcade space shooter released in November 1979 by Atari, Inc. The player controls a spaceship in an asteroid field which is periodically traversed by flying saucers. The object of the game is to shoot and destroy asteroids and saucers while not colliding with either or being hit by the saucers' counter-fire. The game becomes harder as the number of asteroids increases. For this game we don't have flying saucers. This program uses simplegui library to implement GUI.

Here is the code.

Screenshot of game's home screen->

Screeshot of the game in action->

20. RSS News Feed for Google and Yahoo

Many websites have content that is updated on an unpredictable schedule. News sites, such as Google News, are a good example of this. One tedious way to keep track of this changing content is to load the website up in your browser, and periodically hit the refresh button. Fortunately, this process can be streamlined and automated by connecting to the website's RSS feed, using an RSS feed reader instead of a web browser (e.g. Sage). An RSS reader will periodically collect and draw your attention to updated content.

Code can be found here.

Screen shot of the newsfeed->

21. Unique Values from Dictionary

You are given a dictionary aDict that maps integer keys to integer values. Write a Python function that returns a list of keys in aDict that map to dictionary values that appear exactly once in aDict.

  • This function takes in a dictionary and returns a list.
  • Return the list of keys in increasing order.
  • If aDict does not contain any values appearing exactly once, return an empty list.
  • If aDict is empty, return an empty list.

Solution code can be found here.

22. Family Tree

Consider a following tree->

  • zeroth cousin: If two nodes are siblings (have the same immediately preceding ancestor, such as nodes 'H' and 'I') they are zeroth cousins.
  • first cousin: Children of zeroth cousins are first cousins.
  • second cousin: Grandchildren of zeroth cousins are second cousins.
  • In general, i'th cousins have a grandparent or ancestor that is i levels up from their parents.

Suppose two people, P1 and P2, are i'th cousins. Let C1 be a child of P1 and C2 be a child of P2. Then, C1 is an i'th cousin of P2, 1 removed, and C2 is an i'th cousin of P1, 1 removed.Let G1 now be a child of C1. G1 is an i'th cousin of P2, 2 removed.In general, the type of cousin (what 'i' is) is the shorter distance to the ancestor of two people, and the amount removed is the difference between the distance to the common ancestor.

Class Member is a class that represents a single person in the family, and Class Family represents the whole family tree.

You are to write code for the method cousin of the class Family according to the docstring in FamilyTree.py and the definitions for degree removed and cousin type.

Here is the solution code.

Snapshot of the program output->

23. Blog with MongoDB database

I developed this blog step-by-step while completing MongoDB Course on MongoDB University. My part was to write statements to interact with MongoDB. Rest of the part was given as template. This is just a simple blog; nothing fancy!

Github Blackjack Python

You need MongoDB installed and server running to run this application. 'blog.py' is the main file. Restore the database+collection using json file provided in the directory.

You can find the code here.

Here is the screenshot of the blog with dummy user Ashwin logged in to home page->

24. Web Server in Flask - Restaurants and Menus

I developed this web server application while completing Full Stack Foundations course on Udacity. On homepage I display restaurant list and CRUD functionality for each. You can also view menus for each restaurant by clicking on View Menu link. Menu page consists of description, price & course type of each menu. I have also added API endpoints to retrieve Restaurants and Menu data in JSON format.

You can find the code here.

Here is the screenshot of the home page->

Blackjack Game Python Github

Here is Menu page for 'Thyme for That Vegetarian Cuisine' restaurant->

JSON Endpoint reply for menus of a restaurant->

25. Design Patterns with Python

1. Creational Patterns

  1. Factory Method [View Code]
  2. Abstract Factory [View Code]
  3. Singleton [View Code]
  4. Builder [View Code]
  5. Prototype [View Code]

2. Structural Patterns

  1. Decorator [View Code]
  2. Proxy [View Code]
  3. Adapter [View Code]
  4. Composite [View Code]
  5. Bridge [View Code]

Python Github Api

3. Behavioral Patterns

  1. Observer [View Code]
  2. Visitor [View Code]
  3. Iterator [View Code]
  4. Strategy [View Code]
  5. Chain of Responsibility [View Code]
Forked from mjhea0/python_blackjack.py

Github Python Projects

python_blackjack.py
importos
importrandom
deck= [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]*4
defdeal(deck):
hand= []
foriinrange(2):
random.shuffle(deck)
card=deck.pop()
ifcard11:card='J'
ifcard12:card='Q'
ifcard13:card='K'
ifcard14:card='A'
hand.append(card)
returnhand
defplay_again():
again=raw_input('Do you want to play again? (Y/N) : ').lower()
ifagain'y':
dealer_hand= []
player_hand= []
deck= [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]*4
game()
else:
print'Bye!'
exit()
deftotal(hand):
total=0
forcardinhand:
ifcard'J'orcard'Q'orcard'K':
total+=10
elifcard'A':
iftotal>=11: total+=1
else: total+=11
else:
total+=card
returntotal
defhit(hand):
card=deck.pop()
ifcard11:card='J'
ifcard12:card='Q'
ifcard13:card='K'
ifcard14:card='A'
hand.append(card)
returnhand
defclear():
ifos.name'nt':
os.system('CLS')
ifos.name'posix':
os.system('clear')
defprint_results(dealer_hand, player_hand):
clear()
print'The dealer has a '+str(dealer_hand) +' for a total of '+str(total(dealer_hand))
print'You have a '+str(player_hand) +' for a total of '+str(total(player_hand))
defblackjack(dealer_hand, player_hand):
iftotal(player_hand) 21:
print_results(dealer_hand, player_hand)
print'Congratulations! You got a Blackjack!n'
play_again()
eliftotal(dealer_hand) 21:
print_results(dealer_hand, player_hand)
print'Sorry, you lose. The dealer got a blackjack.n'
play_again()
defscore(dealer_hand, player_hand):
iftotal(player_hand) 21:
print_results(dealer_hand, player_hand)
print'Congratulations! You got a Blackjack!n'
eliftotal(dealer_hand) 21:
print_results(dealer_hand, player_hand)
print'Sorry, you lose. The dealer got a blackjack.n'
eliftotal(player_hand) >21:
print_results(dealer_hand, player_hand)
print'Sorry. You busted. You lose.n'
eliftotal(dealer_hand) >21:
print_results(dealer_hand, player_hand)
print'Dealer busts. You win!n'
eliftotal(player_hand) <total(dealer_hand):
print_results(dealer_hand, player_hand)
print'Sorry. Your score isn't higher than the dealer. You lose.n'
eliftotal(player_hand) >total(dealer_hand):
print_results(dealer_hand, player_hand)
print'Congratulations. Your score is higher than the dealer. You winn'
defgame():
choice=0
clear()
print'WELCOME TO BLACKJACK!n'
dealer_hand=deal(deck)
player_hand=deal(deck)
whilechoice!='q':
print'The dealer is showing a '+str(dealer_hand[0])
print'You have a '+str(player_hand) +' for a total of '+str(total(player_hand))
blackjack(dealer_hand, player_hand)
choice=raw_input('Do you want to [H]it, [S]tand, or [Q]uit: ').lower()
clear()
ifchoice'h':
hit(player_hand)
whiletotal(dealer_hand) <17:
hit(dealer_hand)
score(dealer_hand, player_hand)
play_again()
elifchoice's':
whiletotal(dealer_hand) <17:
hit(dealer_hand)
score(dealer_hand, player_hand)
play_again()
elifchoice'q':
print'Bye!'
exit()
if__name__'__main__':
game()
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment