Blog · Jul 25, 2025
Python Beginner Exercises – Focus: Collections, If, While, For,List,Set,Dictionary
🐍 Python Beginner Exercises – Focus: Collections, If, While, For
🔢 Lists
-
Print all elements of a list using a for loop
-
Find the sum of numbers in a list
-
Find the largest number in a list
-
Count even and odd numbers in a list
-
Replace all negative numbers with 0
-
Remove duplicates from a list
-
Find all numbers divisible by 3 and 5 in a list
-
Reverse a list without using .reverse()
-
Create a list of squares of numbers from 1 to 10
-
Search for an element in a list using a loop
🔤 Strings (using collections of characters)
-
Count vowels in a string
-
Reverse a string using a loop
-
Check if a string is a palindrome
-
Remove all spaces from a string
-
Count how many times each character appears (use dictionary)
-
Replace vowels with * in a string
-
Check if two strings are anagrams (basic sorting logic)
-
Count words in a sentence
-
Find the most frequent character in a string
-
Capitalize the first letter of each word (no built-ins)
📦 Dictionaries
-
Count occurrences of elements in a list (frequency count)
-
Merge two dictionaries
-
Find the key with the highest value
-
Print keys and values using a for loop
-
Swap keys and values
-
Sort dictionary by values
-
Remove a key from dictionary using a loop
-
Check if a key exists (with if)
-
Create a dictionary from two lists (zip-like logic)
-
Group words by their first letter into a dictionary
🟰 Sets & Tuples
-
Find common elements in two lists using sets
-
Get all unique values from a list
-
Remove duplicates from a list using set
-
Convert a tuple to list and back
-
Count how many times each item appears in a tuple
🔁 While Loops
-
Print numbers from 1 to 10 using while
-
Keep accepting user input until they type ‘exit’
-
Sum digits of a number using while
-
Factorial using while
-
Basic menu system (1: add, 2: view, 3: quit)