Trabajo Práctico 10

Completar el trabajo práctico en GitHub Classroom

Link al TP 10

Sets

Exercise 1: Unique Characters in a String

Write a Python program that takes a string as input and uses a set to find all the unique characters in that string.

# Example input: "hello"
# Expected output: {'h', 'e', 'l', 'o'}

Dicts

Exercise 1: Find Max Value in Dictionary

Write a Python program that takes a dictionary of student names and their scores and finds the student with the highest score.

# Example input: {'John': 85, 'Emma': 92, 'Sophia': 78}
# Expected output: 'Emma'

Exercise 2: Reverse Dictionary

Given a dictionary, write a Python program to reverse the dictionary (swap keys and values).

# Example input: {'a': 1, 'b': 2, 'c': 3, 'd': 3, 'e': 2}
# Expected output: {1: 'a', 2: 'be', 3: 'cd'}

Exercise 3: Word Frequency Counter

Write a Python program that takes a string and counts the frequency of each word using a dictionary.

# Example input: ["apple", "banana", "apple", "orange", "banana", "apple"]
# Expected output: {'apple': 3, 'banana': 2, 'orange': 1}

Exercise 4: Find biggest expense

Write a Python program that takes a dictionary of expenses and their costs and finds expense with the highest average

# Example input: {'Food': [60, 80, 100], 'Transport': [10, 1, 2], 'Games': [10, 20, 30]}
# Expected output: 'Food'

Exercise 5: Sum of expenses

Write a Python program that takes a dictionary of expenses and their costs and returns a new dict with the sum of all expenses

# Example input: {'Food': [60, 80, 100], 'Transport': [10, 1, 2], 'Games': [10, 20, 30]}
# Expected output: {'Food': 240, 'Transport': 13, 'Games': 60}

Exercise 6: Sum of expenses by type

Write a Python program that takes a dictionary of expenses and their costs and types and returns a new dict with the sum of all expenses by type

# Example input: {'Food': [("A", 60), ("B", 100), ("A", 20)], 'Transport': [("A", 10), ("B", 50), ("C", 5)], 'Games': [("A", 6), ("B", 24), ("C", 99)]}
# Expected output: {'A': 96, 'B': 174, 'C': 104}