diff --git a/Blackjack/README.md b/Blackjack/README.md new file mode 100644 index 00000000..61da7b80 --- /dev/null +++ b/Blackjack/README.md @@ -0,0 +1,30 @@ + +![Star Badge](https://img.shields.io/static/v1?label=%F0%9F%8C%9F&message=If%20Useful&style=style=flat&color=BC4E99) +![Open Source Love](https://badges.frapsoft.com/os/v1/open-source.svg?v=103) + +# Blackjack + +## 🛠️ Description + +This is a simple terminal-based Blackjack game written in Python. The game follows the basic rules of Blackjack: +- Each player is dealt two cards initially. +- You can choose to draw another card (`hit`) or stop drawing (`stand`). +- The goal is to get as close to 21 as possible without going over. +- The dealer (computer) draws cards until the score is 17 or higher. +- Aces are valued as 11, but can convert to 1 if needed. + +The game automatically compares scores and determines the winner at the end. + +## ⚙️ Languages or Frameworks Used + +- Python 3 + +## 🌟 How to run the script + +1. Make sure you have Python 3 installed on your machine. +2. Clone this repository or copy the script into a `.py` file. +3. Open your terminal and navigate to the file directory. +4. Run the script using: + +```bash +python blackjack.py diff --git a/Blackjack/blackjack.py b/Blackjack/blackjack.py new file mode 100644 index 00000000..22e9d081 --- /dev/null +++ b/Blackjack/blackjack.py @@ -0,0 +1,67 @@ +import random + +def deal_card(): + cards = [11, 2, 3 ,4 ,5 ,6, 7, 8, 9, 10, 10, 10, 10] + card = random.choice(cards) + return card + +def calculation_start(cards): + if sum(cards) == 21 and len(cards) == 2: + return 0 + + if 11 in cards and sum(cards) == 21: + cards.remove(11) + cards.append(1) + + return sum(cards) + +def compare(u_score, c_score): + if u_score == c_score: + return "Draw" + elif c_score == 0: + return "You lose, computer has a blackjack!" + elif u_score == 0: + return "You win with a blackjack!" + elif u_score > 21: + return "You went over. You lose!" + elif c_score > 21: + return "Computer went over. You win!" + elif u_score > c_score: + return "You win!" + else: + return "You lose!" + +user_cards = [] +computer_cards = [] +computer_score = -1 +user_score = -1 +game_over = False + +for _ in range(2): + user_cards.append(deal_card()) + computer_cards.append(deal_card()) + +while not game_over: + user_score = calculation_start(user_cards) + computer_score = calculation_start(computer_cards) + + print(f"Your cards are: {user_cards}. Current score is: {user_score}") + print(f"Computer's first card is: {computer_cards[0]}") + + if user_score == 0 or computer_score == 0 or user_score > 21: + game_over = True + else: + user_should_deal = input("Type 'y' to deal another card. Otherwise type 'n': ").lower() + if user_should_deal == 'y': + user_cards.append(deal_card()) + else: + game_over = True + +while computer_score != 0 and computer_score < 17: + computer_cards.append(deal_card()) + computer_score = calculation_start(computer_cards) + +print(f"\nYour final hand is: {user_cards}. Final score is: {user_score}") +print(f"Computer's final hand is: {computer_score}. Final score is: {computer_score}") +print(compare(user_score, computer_score)) + \ No newline at end of file diff --git a/NASA_Image_Extraction/Astro_Images/2022-11-25_NGC 6744 b/NASA_Image_Extraction/Astro_Images/2022-11-25_NGC 6744 new file mode 100644 index 00000000..e69de29b diff --git a/NASA_Image_Extraction/Astro_Images/2022-11-25_NGC 6744: Extragalactic Close-Up.mp3 b/NASA_Image_Extraction/Astro_Images/2022-11-25_NGC 6744: Extragalactic Close-Up.mp3 deleted file mode 100644 index f5611fcf..00000000 Binary files a/NASA_Image_Extraction/Astro_Images/2022-11-25_NGC 6744: Extragalactic Close-Up.mp3 and /dev/null differ diff --git a/Secret_Auction/README.md b/Secret_Auction/README.md new file mode 100644 index 00000000..9a7ec637 --- /dev/null +++ b/Secret_Auction/README.md @@ -0,0 +1,24 @@ + +![Star Badge](https://img.shields.io/static/v1?label=%F0%9F%8C%9F&message=If%20Useful&style=style=flat&color=BC4E99) +![Open Source Love](https://badges.frapsoft.com/os/v1/open-source.svg?v=103) + +# Secret Auction + +## 🛠️ Description + +A simple command-line based secret auction program. Each user inputs their name and bid, and the program stores all bids in a dictionary. After all users have bid, the program reveals the winner with the highest bid. The screen is cleared after each entry to maintain secrecy. + +## ⚙️ Languages or Frameworks Used + +- Python 3 + +## 🌟 How to run the script + +1. Make sure you have Python 3 installed on your machine. +2. Clone this repository or copy the script into a `.py` file (e.g., `auction.py`). +3. Ensure you have the `art.py` module in the same directory, containing the `logo` ASCII art. +4. Open your terminal and navigate to the file directory. +5. Run the script using: + +```bash +python auction.py diff --git a/Secret_Auction/__pycache__/art.cpython-313.pyc b/Secret_Auction/__pycache__/art.cpython-313.pyc new file mode 100644 index 00000000..0dc96332 Binary files /dev/null and b/Secret_Auction/__pycache__/art.cpython-313.pyc differ diff --git a/Secret_Auction/art.py b/Secret_Auction/art.py new file mode 100644 index 00000000..46fc0eca --- /dev/null +++ b/Secret_Auction/art.py @@ -0,0 +1,13 @@ +logo = ''' + ___________ + \ / + )_______( + |"""""""|_.-._,.---------.,_.-._ + | | | | | | ''-. + | |_| |_ _| |_..-' + |_______| '-' `'---------'` '-' + )"""""""( + /_________\\ + .-------------. + /_______________\\ +''' \ No newline at end of file diff --git a/Secret_Auction/secret_auction.py b/Secret_Auction/secret_auction.py new file mode 100644 index 00000000..c7fe4fb0 --- /dev/null +++ b/Secret_Auction/secret_auction.py @@ -0,0 +1,30 @@ +from turtle import clear +from art import logo + +print(logo) + +bids = {} +bidding_finished = False + +def find_highest_bid(bidding_record): + highest_bid = 0 + winner = "" + for bidder in bidding_record: + bidding_amount = bidding_record[bidder] + if bidding_amount > highest_bid: + highest_bid = bidding_amount + winner = bidder + print(f"The winner is {winner}. With a highest bid of ${highest_bid}.") + +while not bidding_finished: + name = input("What is your name? ") + bid = int(input("What is your bid? $")) + bids[name] = bid + + should_continue = input("Are there any bids? Type 'yes' or 'no': ").lower() + if should_continue == "no": + find_highest_bid(bids) + bidding_finished = True + elif should_continue == "yes": + clear() + \ No newline at end of file