0% found this document useful (0 votes)
3 views6 pages

Python Programming Challenges Guide

The document outlines 20 programming problems that cover various concepts such as dictionaries, loops, conditionals, and list comprehensions. Each problem presents a unique challenge, including tasks like calculating averages, filtering duplicates, and performing set operations. The problems are designed to enhance programming skills through practical applications.

Uploaded by

monicathriveni
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views6 pages

Python Programming Challenges Guide

The document outlines 20 programming problems that cover various concepts such as dictionaries, loops, conditionals, and list comprehensions. Each problem presents a unique challenge, including tasks like calculating averages, filtering duplicates, and performing set operations. The problems are designed to enhance programming skills through practical applications.

Uploaded by

monicathriveni
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

🧩 1.

Student Gradebook Analyzer

Problem:
Given a list of student names and their scores in 3 subjects, store the data in a dictionary.
Write a program to

 Calculate the average of each student.


 Find the student with the highest average.
 Print students who failed (average < 40).

Concepts: Variables, Dict, List, Loops, Conditional

🧩 2. Duplicate Word Filter

Problem:
Take a sentence from the user. Split it into words. Remove all duplicate words using a set and
print the unique words in sorted order.

Concepts: Set, String, List, List Comprehension

🧩 3. Character Frequency Counter

Problem:
Take a string and count the frequency of each character using a dictionary. Ignore case and
spaces.

Concepts: Dict, Loops, Conditional, String methods

🧩 4. FizzBuzz with a Twist

Problem:
Print numbers from 1 to 100, but:

 If divisible by 3, print “Fizz”


 If divisible by 5, print “Buzz”
 If divisible by both, print “FizzBuzz”
 Else print the number.

Concepts: Loops, Conditionals, Control Statements


🧩 5. Unique Element Extractor

Problem:
From a list of tuples, extract all unique elements across all tuples.

python
CopyEdit
sample = [(1, 2), (2, 3), (3, 4), (1, 4)]

Output: {1, 2, 3, 4}
Concepts: Tuple, Set, Loops

🧩 6. Shopping Cart Simulation

Problem:
Simulate a cart using a dictionary with items and prices. Allow the user to:

 Add items
 Remove items
 Show total price
 Quit

Concepts: Dict, Loops, Input, Control Statements

🧩 7. List Comprehension Challenge

Problem:
Given a list of numbers from 1 to 100, generate a new list containing:

 Squares of even numbers divisible by 4.

Concepts: List Comprehension, Conditional

🧩 8. Tuple Sorter

Problem:
You’re given a list of tuples like this:

python
CopyEdit
students = [('John', 78), ('Anna', 85), ('Zara', 92)]

Sort by score (descending) and print names.


Concepts: Tuple, List, Sorted with lambda, Loops

🧩 9. Vowel Counter from Dictionary

Problem:
You have a dictionary with names as keys and descriptions as values. Count how many
vowels are in all the descriptions combined.

Concepts: Dict, String, Loops, Conditional

🧩 10. Prime Number Checker with While Loop

Problem:
Ask the user to enter numbers until they type exit. For each number, check if it's prime or
not and display the result.

Concepts: Loops, Conditional, Control Statements, Input

🧩 11. Anagram Checker

Problem:
Take two strings and check if they are anagrams (contain the same letters in any order).
Ignore case and spaces.

Concepts: String, List, Set, Conditional

🧩 12. Bank Account Manager

Problem:
Create a dictionary to represent a bank account. Allow the user to:

 Deposit money
 Withdraw money
 View balance
 Exit

Use while loop and conditionals to handle user input.

Concepts: Dict, Loops, Conditional, Input


🧩 13. Nested Dictionary Summarizer

Problem:
Given a nested dictionary of employees and their monthly salaries, calculate:

 Annual salary of each employee


 The employee with the highest annual salary

python
CopyEdit
salaries = {
'Alice': {'Jan': 5000, 'Feb': 5200, 'Mar': 5100},
'Bob': {'Jan': 6000, 'Feb': 6100, 'Mar': 5900},
}

Concepts: Dict, Loops, Aggregation

🧩 14. Custom Min/Max Without Built-ins

Problem:
Write your own functions to find the minimum and maximum values in a list without using
min() or max().

Concepts: Loops, List, Conditional

🧩 15. Word Frequency Histogram

Problem:
Ask the user for a paragraph. Count the frequency of each word and store it in a dictionary.
Then print words sorted by frequency.

Concepts: Dict, String, Sorting, Loops

🧩 16. Flatten Nested List

Problem:
You are given a list of lists. Flatten it into a single list.

python
CopyEdit
nested = [[1, 2], [3, 4], [5]]

Output: [1, 2, 3, 4, 5]

Challenge: Do it using list comprehension


🧩 17. Number to Word Dictionary

Problem:
Ask the user to enter a number like 452. Print it in words using a dictionary like:

python
CopyEdit
{ '1':'One', '2':'Two', ..., '9':'Nine', '0':'Zero' }

Output: "Four Five Two"

Concepts: Dict, String, Loops

🧩 18. Palindrome List Filter

Problem:
You’re given a list of strings. Return a new list with only the strings that are palindromes.

Concepts: List Comprehension, Conditional, String

🧩 19. Matrix Diagonal Sum

Problem:
Given a 3x3 matrix (as a list of lists), calculate the sum of the main diagonal and secondary
diagonal separately.

python
CopyEdit
matrix = [
[1, 2, 3],
[4, 5, 6],
[7, 8, 9]
]

Output:
Main Diagonal: 1 + 5 + 9 = 15
Secondary Diagonal: 3 + 5 + 7 = 15

Concepts: List, Indexing, Loops

🧩 20. Set Operations Explorer


Problem:
Take two sets of numbers as input (space-separated). Perform:

 Union
 Intersection
 Difference (A - B)
 Symmetric Difference

Concepts: Set operations, Input handling

You might also like