Created
July 16, 2022 22:52
-
-
Save modos/e29220151a7bed7c354ff8d6fe681a98 to your computer and use it in GitHub Desktop.
شطرنج میوه ای
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def is_good(fruit): | |
if fruit['shape'] == 'sphere' and 300 <= fruit['mass'] <= 600 and 100 <= fruit['volume'] <= 500: | |
return True # Fruit is good | |
else: | |
return False # Fruit is bad | |
def fruits(tuple_of_fruits): | |
dict = {} | |
for fruit in tuple_of_fruits: | |
if is_good(fruit): | |
if fruit['name'] in dict: | |
dict[fruit['name']] += 1 | |
else: | |
dict[fruit['name']] = 1 | |
return dict |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment