Updated decorator_exercise.py, dict_merge.py, discounted_list_prices.py & playing_cards.py
This commit is contained in:
parent
5d80470277
commit
1a0816bcef
@ -17,7 +17,7 @@ def factorial(n):
|
||||
return 1 if n == 0 else n * factorial(n - 1)
|
||||
|
||||
# Step 5: Test the decorator
|
||||
print(factorial(20)) # Replace with any number to test
|
||||
print(factorial(2)) # Replace with any number to test
|
||||
|
||||
''' How this code works:
|
||||
This code defines a decorator indicate and three functions avg_two, avg_three, and avg_many_kwargs , each decorated with indicate. Here's a brief description of each component:
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
# Merging two dictionaries in Python
|
||||
dict_a = {'a': 1, 'b': 2}
|
||||
dict_b = {'c': 3, 'd': 4}
|
||||
dict_c = {'e': 5, 'f': 6}
|
||||
|
||||
my_dict = {**dict_a, **dict_b}
|
||||
print(my_dict)
|
||||
my_dict = {**dict_a, **dict_b, **dict_c}
|
||||
print(my_dict)
|
||||
@ -1,7 +1,7 @@
|
||||
# List of product prices
|
||||
product_prices = [1.50, 2.50, 3.00, 0.99, 2.30]
|
||||
|
||||
def apply_discount(prices):
|
||||
def apply_discount(product_prices):
|
||||
prices_copy = product_prices.copy()
|
||||
for index in range(len(prices_copy)):
|
||||
if prices_copy[index] > 2.00:
|
||||
|
||||
@ -75,7 +75,9 @@ if __name__ == "__main__":
|
||||
print(card)
|
||||
print(f"Remaining cards in the deck: {deck.remaining_cards()}")
|
||||
|
||||
'''
|
||||
player1_hand.add_card(Card('Hearts', 'Ace'))
|
||||
print("Player 1's hand after adding an Ace of Hearts:")
|
||||
for card in player1_hand.cards:
|
||||
print(card)
|
||||
'''
|
||||
|
||||
Loading…
Reference in New Issue
Block a user