Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ tambah tolak darab bahagi

Hihi
Hihi
liking men is objectively better than women im not gay

try
krikrikrik
Expand Down
82 changes: 67 additions & 15 deletions import random.py
Original file line number Diff line number Diff line change
@@ -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()
if __name__ == "__main__":
blackjack()
28 changes: 28 additions & 0 deletions import time.py
Original file line number Diff line number Diff line change
@@ -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()