From 1f614ab32920bc46625a1db1deae57bb0a36ee69 Mon Sep 17 00:00:00 2001 From: RANDOMSRANDOM <114931517+RANDOMSRANDOM@users.noreply.github.com> Date: Wed, 16 Apr 2025 12:37:11 +0800 Subject: [PATCH 1/2] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index d306ede..07eda72 100644 --- a/README.md +++ b/README.md @@ -166,6 +166,7 @@ tambah tolak darab bahagi Hihi Hihi +liking men is objectively better than women im not gay try krikrikrik From 047848fefa30ae962e6b615422b44a013b2afadb Mon Sep 17 00:00:00 2001 From: RANDOMSRANDOM <114931517+RANDOMSRANDOM@users.noreply.github.com> Date: Wed, 16 Apr 2025 13:01:04 +0800 Subject: [PATCH 2/2] Add files via upload --- import random.py | 82 +++++++++++++++++++++++++++++++++++++++--------- import time.py | 28 +++++++++++++++++ 2 files changed, 95 insertions(+), 15 deletions(-) create mode 100644 import time.py diff --git a/import random.py b/import random.py index 37d163a..85e1885 100644 --- a/import random.py +++ b/import random.py @@ -1,22 +1,74 @@ import random -import time -def typing_speed_test(): - words = ["elephant", "giraffe", "chocolate", "butterfly", "adventure"] - word = random.choice(words) +def create_deck(): + """Creates a standard 52-card deck.""" + suits = ['Hearts', 'Diamonds', 'Clubs', 'Spades'] + ranks = ['2', '3', '4', '5', '6', '7', '8', '9', '10', 'Jack', 'Queen', 'King', 'Ace'] + return [f"{rank} of {suit}" for suit in suits for rank in ranks] - print("Welcome to Typing Speed Test!") - print(f"Type the following word as fast as you can: {word}") - input("Press Enter to start...") +def calculate_hand_value(hand): + """Calculates the value of a hand in Blackjack.""" + rank_values = {'2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9, '10': 10, + 'Jack': 10, 'Queen': 10, 'King': 10, 'Ace': 11} + value = 0 + aces = 0 - start_time = time.time() - user_input = input("Type here: ") - end_time = time.time() + for card in hand: + rank = card.split(' ')[0] + value += rank_values[rank] + if rank == 'Ace': + aces += 1 - if user_input == word: - time_taken = round(end_time - start_time, 2) - print(f"Great job! You took {time_taken} seconds.") + # Adjust for Aces if value exceeds 21 + while value > 21 and aces: + value -= 10 + aces -= 1 + + return value + +def blackjack(): + print("Welcome to Blackjack!") + deck = create_deck() + random.shuffle(deck) + + # Deal initial hands + player_hand = [deck.pop(), deck.pop()] + dealer_hand = [deck.pop(), deck.pop()] + + print(f"Your hand: {', '.join(player_hand)} (Value: {calculate_hand_value(player_hand)})") + print(f"Dealer's visible card: {dealer_hand[0]}") + + # Player's turn + while calculate_hand_value(player_hand) < 21: + action = input("Do you want to 'hit' or 'stand'? ").lower() + if action == 'hit': + player_hand.append(deck.pop()) + print(f"Your hand: {', '.join(player_hand)} (Value: {calculate_hand_value(player_hand)})") + elif action == 'stand': + break + else: + print("Invalid input. Please type 'hit' or 'stand'.") + + player_value = calculate_hand_value(player_hand) + if player_value > 21: + print("You busted! Dealer wins.") + return + + # Dealer's turn + print(f"\nDealer's hand: {', '.join(dealer_hand)} (Value: {calculate_hand_value(dealer_hand)})") + while calculate_hand_value(dealer_hand) < 17: + dealer_hand.append(deck.pop()) + print(f"Dealer's hand: {', '.join(dealer_hand)} (Value: {calculate_hand_value(dealer_hand)})") + + dealer_value = calculate_hand_value(dealer_hand) + if dealer_value > 21: + print("Dealer busted! You win!") + elif dealer_value > player_value: + print("Dealer wins!") + elif dealer_value < player_value: + print("You win!") else: - print(f"Oops! You typed it incorrectly. The correct word was '{word}'. Try again!") + print("It's a tie!") -typing_speed_test() \ No newline at end of file +if __name__ == "__main__": + blackjack() \ No newline at end of file diff --git a/import time.py b/import time.py new file mode 100644 index 0000000..9afe450 --- /dev/null +++ b/import time.py @@ -0,0 +1,28 @@ +import random + +def slot_machine(): + symbols = ["🍒", "🍋", "🍊", "🍉", "⭐", "💎"] + print("Welcome to the Slot Machine!") + input("Press Enter to spin the reels...") + + # Spin the reels + reel1 = random.choice(symbols) + reel2 = random.choice(symbols) + reel3 = random.choice(symbols) + + # Display the result + print("\n--- Slot Machine ---") + print(f"| {reel1} | {reel2} | {reel3} |") + print("--------------------") + + # Check for a win + if reel1 == reel2 == reel3: + print("🎉 Jackpot! You won! 🎉") + elif reel1 == reel2 or reel2 == reel3 or reel1 == reel3: + print("😊 You got a small win!") + else: + print("😢 Better luck next time!") + +# Run the slot machine +if __name__ == "__main__": + slot_machine() \ No newline at end of file