SET A (MEETS EXPECTATIONS | AVERAGE) SET B (EXCEEDS EXPECTATIONS | EXCELLENT)
Week #3 – Data Types: Tuples and Lists
1. Favorite Colors List 1. Unique Words Extractor
• Ask the user to input their 3 favorite colors, • Ask the user to enter a sentence. Split it into
one at a time, and store them in a list. Then words and store them in a list. Remove duplicates
display the list. and display the unique words in alphabetical
• Skills: List creation, append(), print() order.
• Skills: .split(), set(), list(), sort()
• Sample Output:
Enter favorite color 1: • Sample Output:
Blue Enter a sentence:
Enter favorite color 2: Python is fun and Python is powerful
Green Unique words: ['and', 'fun', 'is', 'powerful',
Enter favorite color 3: 'Python']
Yellow
Your favorite colors are: ['Blue', 'Green', 2. Grades Analyzer
'Yellow'] • Ask the user to input 5 test scores. Store them in a
list. Display the average, highest, and lowest
2. Tuple of Numbers scores.
• Ask the user to enter 3 numbers. Store them • Skills: List operations, sum(), max(), min(), len()
in a tuple, then display the tuple.
• Skills: Tuples, multiple input, data grouping • Sample Output:
Enter score 1: 85
• Sample Output: Enter score 2: 92
Enter number 1: Enter score 3: 76
7 Enter score 4: 88
Enter number 2: Enter score 5: 90
14
Enter number 3: Average score: 86.2
21 Highest score: 92
Numbers tuple: (7, 14, 21) Lowest score: 76
3. List Length Checker 3. Tuple Swapper
• Ask the user to enter items for a shopping • Ask the user to enter two sets of 3 numbers (as
list (comma-separated). Split them into a list tuples). Swap their values and display the results.
and show the number of items. • Skills: Tuples, unpacking, swapping values
• Skills: Lists, .split(), len()
• Sample Output:
• Sample Output: Enter numbers for Tuple A:
Enter your shopping list (separate items with 123
commas): Enter numbers for Tuple B:
milk, bread, eggs, cheese 456
You have 4 items in your shopping list.
Before swap: A = (1, 2, 3), B = (4, 5, 6)
4. Replace an Item in a List After swap: A = (4, 5, 6), B = (1, 2, 3)
• Start with a list of 3 fruits. Ask the user to
replace the second fruit. Display the 4. List Search Tool
updated list. • Create a list of 10 items (you may predefine or ask
• Skills: List indexing, item replacement user to input). Ask the user to input a search term
and check if it's in the list. Display its index or a
• Sample Output: “not found” message.
Original list: ['apple', 'banana', 'cherry'] • Skills: in operator, index(), conditionals
Enter a new fruit to replace banana:
SET A (MEETS EXPECTATIONS | AVERAGE) SET B (EXCEEDS EXPECTATIONS | EXCELLENT)
mango • Sample Output:
Updated list: ['apple', 'mango', 'cherry'] List of items: ['apple', 'banana', 'mango', 'grape',
'orange', 'lemon', 'melon', 'kiwi', 'peach', 'cherry']
5. First and Last in a List Enter item to search: mango
• Ask the user to enter 5 city names. Show the Found at index: 2
first and last city entered.
• Skills: List indexing 5. Contact Directory
• Ask the user to enter 3 names and their
• Sample Output: corresponding phone numbers. Store them as a
Enter city 1: Manila list of tuples. Then allow the user to search by
Enter city 2: Cebu name to display the corresponding number.
Enter city 3: Davao • Skills: Nested structures, tuples in lists, iteration,
Enter city 4: Baguio search logic
Enter city 5: Iloilo
• Sample Output:
First city: Manila Enter name 1: Ana
Last city: Iloilo Enter number 1: 09171234567
Enter name 2: Ben
6. Machine Problem #3: Student Grades Reporter Enter number 2: 09281234567
• Ask the user to enter names and grades for 3 Enter name 3: Carla
students. Store them as a list of tuples, Enter number 3: 09391234567
where each tuple contains the name and
grade (e.g., ("Ana", 89)). Search contact name: Ben
Ben's number is 09281234567
• After input, display each student's name and
grade.
6. Machine Problem #3 (Advanced): Student Grades
• Then, compute and display the class
Analyzer
average.
• Ask the user to enter names and grades for 5
• Skills:
students. Store them as a list of tuples, where
– Tuples, lists
each tuple is in the form ("Name", Grade).
– Looping over a list of tuples
– Basic arithmetic with lists • After input:
– Input and output formatting – Display all students and their grades.
– Display the class average.
– Identify and display the highest and lowest
• Sample Output: scoring students.
Enter name of student 1: Ana – Display the list sorted by grade (descending).
Enter grade of Ana: 89
Enter name of student 2: Ben
Enter grade of Ben: 92 • Skills:
Enter name of student 3: Carla – Tuples, lists
Enter grade of Carla: 85 – Sorting with sorted() and lambda
– Max/min functions with custom keys
Student Grades: – Looping and conditionals
Ana - 89 – String formatting
Ben - 92
Carla - 85 • Sample Output:
Enter name of student 1: Ana
Class average: 88.67 Enter grade of Ana: 89
Enter name of student 2: Ben
Enter grade of Ben: 92
Enter name of student 3: Carla
Enter grade of Carla: 85
Enter name of student 4: Diego
SET A (MEETS EXPECTATIONS | AVERAGE) SET B (EXCEEDS EXPECTATIONS | EXCELLENT)
Enter grade of Diego: 76
Enter name of student 5: Eva
Enter grade of Eva: 95
Student Grades:
Ana - 89
Ben - 92
Carla - 85
Diego - 76
Eva - 95
Class average: 87.4
Highest score: Eva - 95
Lowest score: Diego - 76
Students sorted by grade (high to low):
Eva - 95
Ben - 92
Ana - 89
Carla - 85
Diego - 76