0% found this document useful (0 votes)
9 views

Python assignments

The document provides a comprehensive list of 25 beginner-level Python tasks focused on practicing loops, conditionals, and basic programming concepts. It includes assignments such as printing numbers, calculating sums, generating patterns, and implementing games. The tasks are designed to help learners build foundational skills in Python programming.

Uploaded by

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

Python assignments

The document provides a comprehensive list of 25 beginner-level Python tasks focused on practicing loops, conditionals, and basic programming concepts. It includes assignments such as printing numbers, calculating sums, generating patterns, and implementing games. The tasks are designed to help learners build foundational skills in Python programming.

Uploaded by

ilyasakal993
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 56

Here are 25 beginner-level Python tasks to practice loops (both for and while loops):

1. Basic Printing
Write a loop to print numbers from 1 to 10.

2. Even Numbers
Print all even numbers between 1 and 20 using a loop.

3. Sum of Numbers
Calculate the sum of numbers from 1 to 50 using a loop.

4. Multiplication Table
Print the multiplication table of 5.

5. Factorial
Calculate the factorial of a given number using a loop.

6. Count Digits
Write a loop to count the number of digits in a given number.

7. Reverse a String
Reverse a given string using a loop.

8. Print Odd Numbers


Print all odd numbers between 1 and 30 using a loop.

9. Range and Step


Use a loop to print numbers from 10 to 1 in reverse order.

10. Sum of Even Numbers


Find the sum of all even numbers from 1 to 100 using a loop.

11. Nested Loops: Pattern 1


Print the following pattern:
*
**
***
****
*****

12. Nested Loops: Pattern 2


Print the following pattern:
1
12
123
1234
12345

13. Prime Number


Check if a given number is prime using a loop.

14. List Iteration


Write a loop to iterate through a list of names and print each name.

15. List Sum


Find the sum of all numbers in a list using a loop.

16. Break Statement


Write a loop that stops when it encounters the number 7 in a list.

17. Continue Statement


Write a loop that skips printing numbers divisible by 3 from 1 to 20.

18. Fibonacci Series


Generate the first 10 terms of the Fibonacci series using a loop.

19. User Input and Sum


Ask the user to input 5 numbers and find their sum using a loop.

20. Count Vowels


Count the number of vowels in a given string using a loop.

21. String Palindrome


Check if a given string is a palindrome using a loop.

22. Find Maximum


Find the largest number in a list using a loop.

23. While Loop: Guess the Number


Write a game where the user has to guess a random number. Use a while loop to give multiple
attempts.

24. Nested Loops: Multiplication Table


Print a multiplication table from 1 to 5 using nested loops.

25. Star Pyramid


Print a pyramid pattern:
*
***
*****
*******
*********
Here are some additional beginner-friendly Python assignments to help you practice
foundational concepts:

---

### 1. **Square Numbers in a Range**


- Write a program that asks the user for two numbers: a starting number and an ending
number. Using a `for` loop, print the square of each number in that range (inclusive).

### 2. **Simple Calculator**


- Write a program that asks the user to enter two numbers and an operator (`+`, `-`, `*`, `/`).
Perform the corresponding operation and print the result. Include checks to prevent division by
zero.

---

### 3. **Factorial Calculator**


- Create a program that calculates the factorial of a number entered by the user. Use a `while`
loop to calculate the factorial and display the result.

---

### 4. **Sum of Even and Odd Numbers**


- Write a program that takes an integer input from the user and sums all even numbers and
odd numbers separately from 1 up to that integer. Display both sums.

---

### 5. **Guess the Number Game**


- Create a guessing game where the program randomly picks a number between 1 and 20.
The user tries to guess the number, and the program gives feedback ("too high" or "too low")
until they guess correctly.

### 6. **Multiplication Table**


- Ask the user for a number, and print its multiplication table up to 10 using a `for` loop.

---

### 7. **Check for Prime Numbers**


- Write a program that asks the user for a number and checks if it is a prime number. Use a
loop to test divisibility and display the result.

---

### 8. **Reverse a String**


- Ask the user to enter a string, and then print the string in reverse order.

---

### 9. **Count Vowels in a Sentence**


- Write a program that asks the user to enter a sentence. Count and display the number of
vowels (a, e, i, o, u) in the sentence.

---

### 10. **Temperature Converter**


- Create a program that converts temperatures between Fahrenheit and Celsius. Ask the user
which conversion they want to make and display the converted temperature.

---

### 11. **Find the Largest Number**


- Ask the user to input 5 numbers, one at a time. Store them in a list and use a loop to find and
print the largest number.

---

### 12. **Simple Interest Calculator**


- Write a program to calculate simple interest. Ask the user for the principal amount, rate of
interest, and time in years. Use the formula `interest = (principal * rate * time) / 100` and display
the result.

---

### 13. **Palindrome Checker**


- Write a program that takes a word from the user and checks if it reads the same backward
as forward. Display whether it is a palindrome or not.

---

### 14. **Counting Down with Steps**


- Ask the user for a starting number and a step value. Use a `while` loop to count down from
the starting number to 0 in increments defined by the step, printing each number.
---

### 15. **Sum of Digits**


- Create a program that takes an integer input from the user and calculates the sum of its
digits. For example, if the user enters `123`, the output should be `6`.

---

These assignments cover a wide range of basic programming tasks, including loops,
conditionals, string manipulation, and mathematical calculations. They’re designed to build
comfort with Python’s syntax and fundamental operations. Let me know if you want hints or
further breakdowns for any of these!

Here are some additional beginner Python assignments to keep you practicing:

---

### 1. **FizzBuzz**
- Write a program that prints numbers from 1 to 50. For multiples of 3, print "Fizz" instead of
the number, and for multiples of 5, print "Buzz." For numbers that are multiples of both 3 and 5,
print "FizzBuzz."

---

### 2. **Average Calculator**


- Ask the user to enter several numbers, one at a time. Continue until the user enters 0.
Calculate and display the average of the entered numbers (excluding the 0).

---

### 3. **Letter Count**


- Write a program that asks the user for a word or sentence and a letter. Count how many
times the letter appears in the given input and display the count.

---

### 4. **Generate Random Numbers**


- Use Python’s `random` module to generate 5 random numbers between 1 and 100. Store
them in a list and print the list. Then print the largest and smallest numbers from that list.

---
### 5. **Password Strength Checker**
- Write a program that checks if a user’s password is strong. Ask the user for a password, and
check if it meets these conditions: at least 8 characters, contains at least one number, and
contains both uppercase and lowercase letters. Inform the user if the password is strong or
weak.

---

### 6. **List Manipulation**


- Create a program that initializes an empty list. Then, in a loop, ask the user to add items to
the list. Continue until they enter "stop." Finally, print the list with all the items entered.

---

### 7. **Simple To-Do List**


- Write a program that lets the user create a to-do list. Ask the user to input tasks one at a time
and add them to a list. When they’re done, print the list of tasks.

---

### 8. **Find All Divisors**


- Ask the user for an integer and then print all of its divisors. For example, if the user enters
`12`, the output should be `1, 2, 3, 4, 6, 12`.

---

### 9. **Character Frequency**


- Write a program that takes a word from the user and then displays each unique character
along with the number of times it appears in the word.

---

### 10. **Rock, Paper, Scissors Game**


- Create a simple Rock, Paper, Scissors game that lets the user play against the computer.
Use Python’s `random` module to choose a move for the computer. Play one round and display
who won.

---

### 11. **Find Prime Numbers in a Range**


- Ask the user for two numbers to define a range. Print all prime numbers within that range.

---
### 12. **Sum of a Range**
- Write a program that asks the user for a starting number, an ending number, and a step
value. Using a loop, calculate and print the sum of all numbers from the starting number up to
but not including the ending number, with the specified step.

---

### 13. **Simple Interest or Compound Interest**


- Create a program that first asks the user whether they want to calculate simple interest or
compound interest. Then ask for the necessary values (principal, rate, time, and in the case of
compound interest, the number of times interest is compounded). Display the calculated
interest.

---

### 14. **Basic Number Statistics**


- Ask the user to enter numbers one at a time. Continue until they enter 0. At the end, display
the total sum, the average, and the maximum number entered.

---

### 15. **Word Count in a Sentence**


- Write a program that takes a sentence from the user and prints the total number of words in
it.

---

### 16. **Remove Duplicates**


- Ask the user to enter a list of items (or words) separated by spaces. Remove any duplicates
and display the unique list of items.

---

### 17. **Number Guessing Game with Range**


- Write a guessing game where the computer picks a random number between two numbers
specified by the user. The user then tries to guess the number, and the program provides
feedback ("too high" or "too low") until they get it right.

---

### 18. **Reverse List of Numbers**


- Ask the user to enter a series of numbers. Store them in a list, then print the list in reverse
order.
---

### 19. **Shopping Cart Total**


- Create a program where the user can enter the price of each item in their shopping cart.
Keep a running total and display the final total when they are done.

---

### 20. **Count Words Ending with a Specific Letter**


- Write a program that takes a sentence from the user and a specific letter. Count how many
words in the sentence end with that letter.

---

These assignments will give you plenty of opportunities to work with Python’s core concepts,
such as loops, conditionals, lists, and string manipulation. Let me know if you need more
specific guidance on any of these!

Here are some beginner-level Python assignments to practice loops, along with `break`,
`continue`, and `else` statements:

### 1. Count Down


Write a program that uses a `while` loop to print numbers from 10 down to 1. When the loop is
done, print "Liftoff!"

​ ​
​ ​ i = 10
while i > 0:
print(i)
i -= 1
else:
print("liftoff!")

### 2. Print Odd Numbers


Using a `for` loop, print only the odd numbers from 1 to 20. Use the `continue` statement to skip
even numbers.

for i in range(1,20):
if i % 2 == 0:
continue
print(i)
### 3. Sum of Numbers
Write a `while` loop that keeps asking the user to enter a number. Add each number to a
running total. If the user enters 0, break the loop and print the total sum of the numbers entered.

i=0
while True:
n = int(input("enter a number: "))
if n == 0:
break
i += n
print(i)

### 4. Multiplication Table


Create a `for` loop to print the multiplication table of 5 (i.e., 5x1, 5x2, etc., up to 5x10). When the
loop reaches 5x5, use the `break` statement to stop.

### 5. Count to Target


Write a program that asks the user for a target number. Then, use a `while` loop to count from 1
up to that target number. When the loop finishes, use an `else` statement to print "Reached the
target!"

### 6. Skip Multiples of 3


Write a program with a `for` loop to print numbers from 1 to 10. Use the `continue` statement to
skip printing multiples of 3.

### 7. Password Prompt


Write a program that uses a `while` loop to ask the user for a password. If the entered password
is "python123," print "Access granted" and break the loop. Otherwise, keep asking until they
enter the correct password.

Let me know if you'd like examples or hints on any of these assignments!

Here are beginner-level Python assignments for each topic you've listed. These will help you get
hands-on practice with fundamental Python concepts.

---

### 1. **Python Intro**


- **Assignment**: Write a short script that prints "Hello, Python!" to the console. Try running
the code to see your first output in Python.

### 2. **Python Get Started**


- **Assignment**: Set up Python on your computer. Write a script that prints "Python is set up
and running!" and run it to confirm.

### 3. **Python Syntax**


- **Assignment**: Write a script that prints three lines, with one sentence on each line:
- "Python is fun!"
- "Python syntax is easy to learn."
- "Let's start coding in Python!"

### 4. **Python Comments**


- **Assignment**: Write a Python script with the following:
- A comment at the beginning saying what the script does.
- Code to print your name.
- Add a comment above the code line explaining it.

### 5. **Python Variables**


- **Assignment**: Create variables to store your name, age, and city. Print these details in a
sentence like: "My name is [name], I'm [age] years old, and I live in [city]."

### 6. **Python Data Types**


- **Assignment**: Declare variables of each type: string, integer, float, and boolean. Print each
variable with its type using the `type()` function.

### 7. **Python Numbers**


- **Assignment**: Create two variables with numbers, `a` and `b`. Calculate and print the
following:
- Sum (`a + b`)
- Difference (`a - b`)
- Product (`a * b`)
- Quotient (`a / b`)

### 8. **Python Casting**


- **Assignment**: Create a float variable with a decimal number. Convert it to an integer and
print both the original float and the converted integer.

### 9. **Python Strings**


- **Assignment**: Write a script that takes a name as input and:
- Prints the name in uppercase.
- Prints the first letter.
- Prints the length of the name.

### 10. **Python Booleans**


- **Assignment**: Create two variables, `is_sunny` and `is_weekend`, and set them to either
`True` or `False`. Write an if-else statement that prints "Let's go out!" if both are `True`, and
"Maybe another day." otherwise.

### 11. **Python Operators**


- **Assignment**: Create two numbers, `x` and `y`, and print:
- Whether `x` is greater than `y`.
- Whether `x` equals `y`.
- Whether `x` is not equal to `y`.

### 12. **Python Lists**


- **Assignment**: Create a list of five of your favorite foods. Print:
- The first item.
- The last item.
- The entire list in reverse order.

### 13. **Python Tuple**


- **Assignment**: Create a tuple with three of your favorite movies. Try to change one of the
items and see what happens (tuples are immutable). Print the tuple after attempting the change.

---

Each assignment encourages exploration of a core Python concept. Let me know if you need
any explanations or solutions!

Here are some beginner-friendly Python assignments focusing on variables:

---

### 1. **Basic Variable Assignment**


- **Task**: Create three variables to store your name, age, and favorite color. Print a sentence
that includes all three, like:
`"My name is [name], I am [age] years old, and my favorite color is [color]."`

### 2. **Swapping Variables**


- **Task**: Create two variables, `a` and `b`, and assign them any numbers you like. Swap
their values without directly reassigning, using a third variable, and print their values after
swapping.

### 3. **Variable Types**


- **Task**: Create variables of each type: `string`, `integer`, `float`, and `boolean`. Print each
variable's value and its type using the `type()` function to confirm.

### 4. **Concatenation with Variables**


- **Task**: Create variables for your first name and last name. Concatenate them to make a
full name and print it.

### 5. **Simple Calculator**


- **Task**: Create two variables, `num1` and `num2`, and assign them numbers. Calculate and
print:
- Sum of `num1` and `num2`
- Difference (`num1 - num2`)
- Product (`num1 * num2`)
- Quotient (`num1 / num2`)

### 6. **Using Variables in a Sentence**


- **Task**: Store your city, country, and favorite food in variables. Print a sentence like:
`"I live in [city], [country], and I love eating [favorite food]."`

### 7. **Updating Variables**


- **Task**: Create a variable `count` and set it to 10. Increase `count` by 5, then decrease it by
3, and finally multiply it by 2. Print the final result of `count`.

### 8. **Temperature Conversion**


- **Task**: Create a variable `celsius` to store a temperature in Celsius. Convert it to
Fahrenheit using the formula `F = (C * 9/5) + 32` and print both Celsius and Fahrenheit values.

### 9. **String Variables and Length**


- **Task**: Store your favorite quote in a variable called `quote`. Print the quote along with the
number of characters it contains.

### 10. **Area of a Rectangle**


- **Task**: Assign values to two variables, `length` and `width`, for the dimensions of a
rectangle. Calculate and print the area of the rectangle (`area = length * width`).

---

These exercises will help you practice variable declaration, assignment, and manipulation in
Python! Let me know if you'd like any explanations or hints.

Here are beginner-level Python assignments combining **data types** and **variables** to
deepen your understanding of both:

---

### 1. **Identify Data Types**


- **Task**: Create variables of each primary data type: string, integer, float, and boolean. For
example:
```python
name = "Alice" # string
age = 25 # integer
height = 5.6 # float
is_student = True # boolean
```
- Print each variable along with its data type using the `type()` function.

### 2. **Arithmetic Operations with Variables**


- **Task**: Create two integer variables, `a` and `b`. Use them to calculate:
- Sum (`a + b`)
- Difference (`a - b`)
- Product (`a * b`)
- Quotient (`a / b`)
- Print the results with descriptions, like: "The sum of a and b is [result]".

### 3. **String Manipulation**


- **Task**: Create a string variable `phrase` with a short sentence. Write code to:
- Print the sentence in uppercase.
- Print the sentence in lowercase.
- Print the length of the sentence.
- Print the first character of the sentence.

### 4. **Boolean Comparison**


- **Task**: Create two numeric variables, `x` and `y`, and assign them any values you like.
Write code to:
- Check if `x` is greater than `y` and print the result.
- Check if `x` is equal to `y` and print the result.
- Check if `x` is not equal to `y` and print the result.

### 5. **Type Conversion (Casting)**


- **Task**: Create a float variable with a decimal number, e.g., `my_float = 7.89`.
- Convert it to an integer and print both the original float and the converted integer.
- Convert it to a string and print the new value and its type.

### 6. **User Input and Data Types**


- **Task**: Write a script that asks the user for their age, height, and whether they are a
student (True/False). Convert each input to the appropriate data type and print a summary:
- Age as an integer
- Height as a float
- Student status as a boolean

### 7. **Simple Interest Calculator**


- **Task**: Create three variables, `principal` (float), `rate` (float), and `time` (integer). Use
them to calculate simple interest with the formula:
\[
\text{interest} = \text{principal} \times \text{rate} \times \text{time} / 100
\]
- Print the interest.

### 8. **Temperature Conversion (Data Types and Variables)**


- **Task**: Create a variable `celsius` and assign it a float value. Convert it to Fahrenheit using
the formula `F = (C * 9/5) + 32`. Print both Celsius and Fahrenheit values.

### 9. **List of Mixed Data Types**


- **Task**: Create a list that contains different data types (e.g., a string, integer, float, and
boolean). Print each element and its data type using a loop.

### 10. **Character Count in String**


- **Task**: Create a string variable `sentence` with any short sentence. Use `len()` to find the
number of characters in the string. Then, count and print how many times a specific character
(e.g., "a") appears in the sentence.

---

These assignments focus on practicing with data types and variables, including string
manipulation, arithmetic operations, and type conversion. Let me know if you need hints or
solutions for any of them!

Here are real-world inspired Python assignments focusing on **data types** and **variables**:

---

### 1. **Currency Converter**


- **Task**: Write a program that converts currency from US Dollars to Euros. Create variables
for the amount in USD and the conversion rate (e.g., 1 USD = 0.85 EUR). Multiply these values
to get the amount in Euros, then print the result in a formatted statement:
`"100 USD is equivalent to 85 Euros."`

### 2. **BMI Calculator**


- **Task**: Build a Body Mass Index (BMI) calculator. Create variables for weight (in kg) and
height (in meters). Use the formula `BMI = weight / (height ** 2)` to calculate BMI, then print it
with a message indicating the result:
- `"Your BMI is [BMI], which is considered healthy."`

### 3. **Tip Calculator**


- **Task**: Create a simple tip calculator. Set up variables for `bill_amount` and
`tip_percentage` (e.g., 15%). Calculate the tip by multiplying the bill amount by the tip
percentage, then print the total bill with a message:
- `"For a bill of [bill_amount], a 15% tip would be [tip], making the total [total_bill]."`

### 4. **Temperature Conversion Application**


- **Task**: Write a program that lets the user input a temperature in Fahrenheit. Convert it to
Celsius using the formula `C = (F - 32) * 5/9`. Print both the Fahrenheit and Celsius values in a
clear statement:
- `"100 degrees Fahrenheit is equal to 37.78 degrees Celsius."`

### 5. **Loan EMI Calculator**


- **Task**: Create a loan EMI (Equated Monthly Installment) calculator. Variables required:
- `principal` (loan amount), `rate` (interest rate per annum), and `time` (loan period in years).
- Use the formula for EMI calculation:
\[
EMI = \frac{{\text{principal} \times \text{rate} \times (1 + \text{rate})^{\text{time}}}}{{(1 +
\text{rate})^{\text{time}} - 1}}
\]
- Print out the EMI, stating: `"The EMI for a loan of [principal] over [time] years at [rate] interest
rate is [EMI]."`

### 6. **Electricity Bill Calculator**


- **Task**: Create a script that calculates an electricity bill. Define variables for
`units_consumed` and `cost_per_unit`. Multiply these to get the total bill. Print the total with a
message:
- `"For [units_consumed] units at [cost_per_unit] per unit, the total electricity bill is
[total_cost]."`

### 7. **Distance Between Two Points**


- **Task**: Write a program that calculates the distance between two geographical points.
Define variables for latitude and longitude of both points. Use the Haversine formula to calculate
the distance and print the result.

### 8. **Travel Time Estimator**


- **Task**: Create a script that estimates travel time based on speed and distance. Define
variables `distance` (km) and `speed` (km/h). Calculate travel time with `time = distance /
speed`. Print the result:
- `"At [speed] km/h, it will take [time] hours to cover [distance] km."`

### 9. **Discount Calculator**


- **Task**: Write a program that applies a discount to a purchase. Define variables for
`original_price` and `discount_percentage`. Calculate and print the final price after applying the
discount:
- `"The final price after a [discount_percentage]% discount on [original_price] is
[final_price]."`

### 10. **Area and Circumference of a Circle**


- **Task**: Create variables for `radius` and calculate both the area and circumference of a
circle using:
- Area: \(\pi \times \text{radius}^2\)
- Circumference: \(2 \times \pi \times \text{radius}\)
- Print both results with descriptive statements.

---

These assignments will make data types and variables feel more relevant to real-world
situations. Let me know if you need any guidance with these!

Here are real-world inspired Python problems focused on practicing **conditional statements**:

---

### 1. **Online Shopping Discount Calculator**


- **Task**: Write a program that applies a discount based on the total shopping amount:
- If the amount is over $100, apply a 10% discount.
- If the amount is between $50 and $100, apply a 5% discount.
- If the amount is below $50, no discount is applied.
- Print the final amount after the discount.

### 2. **Age-based Movie Ticket Price**


- **Task**: Write a script to determine the movie ticket price based on age:
- Age < 12: $8
- Age 12–18: $12
- Age 18–60: $15
- Age 60+: $10
- Ask the user for their age, then print the ticket price.

### 3. **Temperature Feedback**


- **Task**: Create a program that accepts a temperature (in Celsius) and prints a message:
- Temperature > 30°C: "It's hot outside, stay hydrated!"
- Temperature 20–30°C: "It's a pleasant day."
- Temperature < 20°C: "It's cold outside, dress warmly!"

### 4. **Simple Grade Calculator**


- **Task**: Write a program that takes a student’s score (0–100) and prints their grade:
- 90 and above: "Grade A"
- 80–89: "Grade B"
- 70–79: "Grade C"
- 60–69: "Grade D"
- Below 60: "Fail"

### 5. **Bank Loan Eligibility Checker**


- **Task**: Create a script that checks loan eligibility:
- If the user’s age is 21 or above and they have a monthly income of $3000 or more, they are
eligible for a loan.
- If they don’t meet both conditions, print that they are ineligible.

### 6. **Fitness Tracker Daily Steps Goal**


- **Task**: Write a program that takes the number of steps a user walked today and provides
feedback:
- 10,000+ steps: "Amazing! You've reached your goal."
- 5,000–9,999 steps: "Good job! Keep going to reach your goal."
- Below 5,000 steps: "Try to walk a bit more to meet your goal."

### 7. **Restaurant Meal Rating System**


- **Task**: Ask the user to rate their meal experience from 1 to 5 stars and give feedback:
- 5 stars: "Thank you! We're glad you loved it!"
- 4 stars: "Thank you! We're happy you enjoyed your meal."
- 3 stars: "Thank you for your feedback!"
- 2 stars: "Sorry to hear it wasn't great. We'll improve!"
- 1 star: "We're really sorry. We'll work hard to make things better."

### 8. **Traffic Light Simulator**


- **Task**: Write a program that simulates a traffic light:
- If the light color is "Green," print "Go."
- If the light color is "Yellow," print "Slow down."
- If the light color is "Red," print "Stop."
- Use an input for the light color.

### 9. **Simple Password Validator**


- **Task**: Create a program that checks if a user’s password meets these criteria:
- At least 8 characters long.
- Contains at least one digit.
- Contains at least one uppercase letter.
- Print "Password is valid" if all conditions are met; otherwise, print which condition is missing.

### 10. **School Attendance Requirement**


- **Task**: Write a program that checks if a student can take their final exam based on
attendance:
- If the student's attendance rate is 75% or more, print "Eligible for the final exam."
- Otherwise, print "Ineligible for the final exam."
---

These problems will help you practice using `if`, `elif`, and `else` statements in various real-life
scenarios. Let me know if you need any help with solutions or explanations!

Here are five beginner-friendly Python project ideas to help you learn key programming
concepts:

### 1. **Simple Calculator**


- **Description**: Create a basic calculator that can perform addition, subtraction,
multiplication, and division.
- **Skills Covered**: Functions, conditionals, loops, error handling.
- **Additional Challenge**: Add more operations like exponentiation and square roots, and
handle invalid inputs gracefully.

### 2. **To-Do List App (CLI)**


- **Description**: Build a command-line to-do list app where users can add, view, and remove
tasks.
- **Skills Covered**: Lists, dictionaries, input handling, file handling (to save tasks).
- **Additional Challenge**: Save the to-do list to a text file so that it persists when you restart
the program.

### 3. **Number Guessing Game**


- **Description**: Create a game where the program randomly selects a number within a
range (e.g., 1–100), and the player has to guess it. The program should give hints if the guess is
too high or too low.
- **Skills Covered**: Random number generation, loops, conditionals.
- **Additional Challenge**: Add a limit on the number of guesses, and provide feedback to the
player on how close they are to the correct answer.

### 4. **Basic Personal Budget Tracker**


- **Description**: Build a simple budget tracker where users can input their income and
expenses and see a summary.
- **Skills Covered**: Lists, dictionaries, functions, input/output handling.
- **Additional Challenge**: Add categories for expenses and display a breakdown by category.
Optionally, save the data to a file for persistence.

### 5. **Password Generator**


- **Description**: Create a password generator that can create random passwords of a
specified length. Users should be able to choose options like including uppercase letters,
numbers, and special characters.
- **Skills Covered**: String manipulation, loops, conditionals, random module.
- **Additional Challenge**: Add options to exclude specific characters or generate passwords
that follow specific patterns.

Let me know if you’d like further details on any of these or if you want hints on starting them!

Here are five more beginner Python project ideas that will help you deepen your understanding
of programming concepts:

### 6. **Weather App (CLI)**


- **Description**: Create a command-line app that fetches and displays the current weather for
a given city using a public weather API.
- **Skills Covered**: HTTP requests, working with APIs, parsing JSON data, error handling.
- **Additional Challenge**: Allow users to search for multiple cities and save recent searches
to a file.

### 7. **Flashcard Quiz**


- **Description**: Build a flashcard app that lets users create a set of flashcards and then quiz
themselves.
- **Skills Covered**: Lists, dictionaries, loops, file handling (to save flashcards).
- **Additional Challenge**: Allow the user to mark cards as "mastered" and only quiz on
remaining cards.

### 8. **Unit Converter**


- **Description**: Develop a simple unit converter that converts between units (e.g., kilometers
to miles, Celsius to Fahrenheit).
- **Skills Covered**: Functions, conditionals, basic arithmetic.
- **Additional Challenge**: Add more unit types like time, weight, and currency conversions,
and use dictionaries to store conversion factors.

### 9. **Simple Contact Book**


- **Description**: Build a command-line contact book where users can add, search, edit, and
delete contacts.
- **Skills Covered**: Dictionaries, file handling, functions, conditionals.
- **Additional Challenge**: Save the contact book to a file so it persists between sessions, and
add functionality for multiple phone numbers and email addresses.

### 10. **Hangman Game**


- **Description**: Create a basic Hangman game where users guess letters to reveal a hidden
word.
- **Skills Covered**: Strings, lists, loops, conditionals.
- **Additional Challenge**: Add a graphical interface using `tkinter` or create different levels of
difficulty by varying word lengths.
If you want further guidance on any of these, feel free to ask! These projects will help you cover
various core Python topics and improve your problem-solving skills.

Here are a few examples of programs that would likely require around 100 lines of code or
more, providing a good challenge and covering the skills employers look for:

### 1. **Bank Account Management System**


- **Description**: Create a console-based application that lets users create, view, and manage
bank accounts. Each account should have details like account number, balance, and account
holder’s name.
- **Features**:
- Add a new account.
- View balance and account details.
- Deposit and withdraw money with basic error handling (e.g., preventing overdrafts).
- Search for accounts by account number or holder's name.
- **Skills Practiced**: Object-oriented programming (OOP), input handling, file storage for
saving account data.

### 2. **Simple Student Grading System**


- **Description**: Build a grading system where teachers can add students, record their
grades, and view their average scores.
- **Features**:
- Add and remove students.
- Record grades for each student across multiple subjects.
- Calculate average grades for each student and display them.
- Generate a report card for each student with all subjects and averages.
- **Skills Practiced**: Lists, dictionaries, loops, functions, basic data manipulation.

### 3. **Expense Tracker**


- **Description**: Develop an expense tracking tool where users can log their expenses and
see summaries.
- **Features**:
- Add, view, and delete expenses, with categories like food, transportation, or entertainment.
- Calculate total expenses and display a summary by category.
- Save data to a file so that it persists between program runs.
- Generate reports for a specific date range.
- **Skills Practiced**: File I/O, data manipulation, lists, dictionaries, basic math operations.

### 4. **Flashcard Quiz App**


- **Description**: Build an app that quizzes users on predefined topics using flashcards.
- **Features**:
- Load questions and answers from a file or database.
- Shuffle and present questions randomly to the user.
- Track correct and incorrect answers, and calculate the score at the end.
- Allow users to mark certain questions as “learned” and skip them in the next quiz session.
- **Skills Practiced**: File handling, random module, lists and dictionaries, conditional logic,
loops.

### 5. **Command-Line To-Do List Manager**


- **Description**: Create a to-do list application that lets users manage tasks from the
command line.
- **Features**:
- Add, edit, and delete tasks.
- Mark tasks as complete or incomplete.
- Display tasks based on their status (e.g., pending, completed).
- Save tasks to a file so they’re available the next time the program is run.
- **Skills Practiced**: File I/O, loops, lists, dictionaries, basic CRUD operations.

### 6. **Personalized Text-Based Adventure Game**


- **Description**: Write a simple adventure game where users explore rooms, pick up items,
and face simple challenges or puzzles.
- **Features**:
- Create different rooms with unique descriptions and items.
- Allow players to navigate between rooms, interact with objects, and collect items.
- Include a scoring or inventory system based on the items collected.
- Optionally, add simple puzzles that players need to solve to progress.
- **Skills Practiced**: Control flow, functions, dictionaries, string manipulation, user input
handling.

### 7. **Library Management System**


- **Description**: Develop a console-based system to manage a small library’s collection of
books.
- **Features**:
- Add, view, and remove books with details like title, author, genre, and availability.
- Allow users to search for books by title or author.
- Track which books are checked out and manage due dates.
- **Skills Practiced**: Classes and objects, file handling, lists, dictionaries, date and time
functions.

These projects will help you practice multiple aspects of Python programming while working with
real-world scenarios, which is invaluable for job preparation. Let me know if you need help
starting any of them!

Here are a few more beginner-friendly Python projects that can be expanded to around 100
lines and beyond, helping you cover a range of practical skills:

### 8. **Inventory Management System**


- **Description**: Create a simple system for managing an inventory of products, which could
be used by a small store or individual.
- **Features**:
- Add, update, and delete products with details like name, quantity, price, and category.
- Search products by name or category.
- Track stock levels and alert the user if certain items fall below a minimum threshold.
- Generate a report showing all items in stock with their values.
- **Skills Practiced**: Classes, file I/O, dictionaries, loops, conditionals, data handling.

### 9. **Quiz Application**


- **Description**: Build a multiple-choice quiz application that allows users to take quizzes on
various topics.
- **Features**:
- Load quiz questions from a file.
- Display one question at a time with multiple-choice options.
- Track user answers and calculate a score at the end.
- Provide feedback at the end with correct answers and explanations (if available).
- **Skills Practiced**: Lists, file handling, loops, conditionals, data validation.

### 10. **Simple ATM Simulator**


- **Description**: Create a command-line ATM simulator that mimics basic banking
transactions.
- **Features**:
- Allow users to "log in" with an account ID and PIN.
- Perform actions like checking balance, depositing money, withdrawing money (with
overdraft protection), and exiting.
- Update the balance after each transaction and store it for future sessions.
- **Skills Practiced**: Input handling, conditionals, loops, file I/O, and basic arithmetic
operations.

### 11. **Recipe Manager**


- **Description**: Build an app where users can save, view, and organize recipes.
- **Features**:
- Allow users to add new recipes with ingredients, instructions, and a category (like dessert,
main course, etc.).
- Search for recipes by name or ingredient.
- Edit or delete recipes as needed.
- Store recipes in a file to preserve them between sessions.
- **Skills Practiced**: File handling, lists and dictionaries, string manipulation, basic data
organization.

### 12. **Simple Email Sender**


- **Description**: Create a program that sends emails through an SMTP server (e.g., Gmail).
- **Features**:
- Collect user input for the email address, subject, and body of the message.
- Use the `smtplib` library to send the email.
- Implement error handling for connection issues, authentication errors, etc.
- **Skills Practiced**: Libraries (`smtplib`), handling user input, error handling, data validation.
- **Note**: Make sure to follow best practices with sensitive data (e.g., don’t hardcode email
passwords).

### 13. **Digital Clock (with GUI)**


- **Description**: Create a digital clock using the `tkinter` library to display the current time.
- **Features**:
- Display the current time in a user-friendly format.
- Update the time every second.
- Style the clock display with custom colors and fonts.
- **Skills Practiced**: GUI programming, working with `tkinter`, handling time with the `time` or
`datetime` library, basic event-driven programming.

### 14. **BMI Calculator**


- **Description**: Create a calculator that lets users enter their weight and height to calculate
their Body Mass Index (BMI).
- **Features**:
- Collect user input for weight (in kg or lbs) and height (in cm or inches).
- Calculate and display the BMI with an appropriate category (e.g., underweight, normal,
overweight).
- Provide feedback or health tips based on the BMI range.
- **Skills Practiced**: Functions, input validation, conditionals, arithmetic operations, basic
data validation.

### 15. **Random Quote Generator**


- **Description**: Build an app that displays a random quote from a predefined list or file each
time it runs.
- **Features**:
- Load quotes from a file or list and select a random quote to display.
- Allow users to add new quotes.
- Provide an option to save favorite quotes to a separate file.
- **Skills Practiced**: File handling, random module, lists, basic input handling, and string
manipulation.

### 16. **Daily Journal Application**


- **Description**: Create a simple journal application that lets users record their daily thoughts.
- **Features**:
- Add a new journal entry for the current date.
- View all past entries, categorized by date.
- Save each entry to a file or database so it persists between sessions.
- **Skills Practiced**: File I/O, lists, dictionaries, date and time handling, string manipulation.
Each of these projects provides good practice with core Python skills and teaches you to
structure larger pieces of code, making them great for skill-building on the way to more
advanced applications. Let me know if you want guidance on any specific project!

Here are 10 Python project ideas that showcase different skills and are great for job
interviews. Each project demonstrates real-world problem-solving and practical application of
Python concepts:

1. Task Automation (Skill: Scripting)

●​ Project: Develop a script that automates a repetitive task, like renaming multiple files,
scraping data from websites, or generating email reports.
●​ Tech: Use os, shutil, and selenium or beautifulsoup4 for web scraping.
●​ Example: A script to download stock prices and generate a daily report in Excel using
openpyxl.

2. Data Analysis Dashboard (Skill: Data Analysis)

●​ Project: Create a program that analyzes sales or user data and displays visualizations.
●​ Tech: Use pandas for analysis and matplotlib or seaborn for visualization.
●​ Example: Analyze e-commerce data (orders, revenue) and create graphs of trends.

3. Personal Expense Tracker (Skill: File Handling, GUIs)

●​ Project: Build a tracker where users can log expenses, categorize them, and view
monthly summaries.
●​ Tech: Use Tkinter for a GUI or Flask for a web-based solution.
●​ Example: Save expense data in a CSV or SQLite database and generate monthly
reports.
4. API Integration Project (Skill: Working with APIs)

●​ Project: Build an application that consumes data from public APIs, such as weather
forecasts, movie databases, or financial APIs.
●​ Tech: Use requests to fetch data and process it.
●​ Example: A weather app that shows a 7-day forecast and sends alerts for bad weather.

5. Game Development (Skill: Logic, Creativity)

●​ Project: Create a simple game like Tic-Tac-Toe, Snake, or Sudoku.


●​ Tech: Use pygame or basic Python logic.
●​ Example: A memory game where players match cards.

6. Chatbot (Skill: Natural Language Processing)

●​ Project: Build a chatbot that can answer FAQs or hold simple conversations.
●​ Tech: Use NLTK, spaCy, or transformers for natural language processing.
●​ Example: A chatbot that assists with customer support or provides restaurant
recommendations.

7. Web Scraper (Skill: Web Scraping, Data Handling)

●​ Project: Develop a scraper to collect data from a website, such as job postings, product
prices, or news articles.
●​ Tech: Use BeautifulSoup or Scrapy.
●​ Example: Scrape prices from e-commerce websites and notify users of price drops.

8. Password Manager (Skill: Cryptography)

●​ Project: Create a secure password manager that stores encrypted passwords for
different accounts.
●​ Tech: Use cryptography for encryption and a database like SQLite for storage.
●​ Example: Provide a CLI or GUI interface for managing accounts securely.

9. Machine Learning Model (Skill: Machine Learning)

●​ Project: Build a simple machine learning model, like predicting house prices or customer
churn.
●​ Tech: Use scikit-learn for model building and matplotlib for visualizations.
●​ Example: Train a model to classify emails as spam or non-spam.

10. Portfolio Website Generator (Skill: Web Development)

●​ Project: Create a Python program that generates a static portfolio website for
developers based on user input.
●​ Tech: Use Jinja2 for templates and Flask for backend.
●​ Example: Users input their skills and projects, and the app generates an
HTML/CSS-based portfolio.

Bonus Tips for Interviews:

1.​ Choose a Relevant Domain: Tailor the project to align with the company’s industry.
2.​ Showcase Modular Code: Use functions, classes, and clean code practices.
3.​ Highlight Scalability: Show how the project can be extended or improved.
4.​ Document Well: Provide a README file with installation and usage instructions.
5.​ Deploy Your Projects: Use platforms like GitHub, Heroku, or Streamlit to demonstrate
live projects.

Here are a few beginner Python program ideas, similar to the To-Do List program, to help you
practice and strengthen your skills:
1. Simple Calculator

Objective: Create a simple calculator that performs basic operations (addition, subtraction,
multiplication, division).

Features:

●​ Take two numbers as input.


●​ Perform addition, subtraction, multiplication, or division based on user choice.

2. Number Guessing Game (with a twist)

Objective: Create a guessing game where the computer randomly picks a number, and the
player has to guess it. After each guess, provide feedback ("too high", "too low", or "correct").

3. Simple Contact Book

Objective: Create a simple contact book that allows the user to add, view, and search for
contacts by name.

4. Simple Voting System

Objective: Create a program that asks the user to vote for one of three candidates. After voting,
display the total number of votes each candidate received.

5. Palindrome Checker
Objective: Create a program that checks if a word entered by the user is a palindrome (i.e., a
word that reads the same forward and backward).

6. Simple ATM System

Objective: Simulate an ATM where the user can check their balance, deposit money, or
withdraw money. It keeps track of the balance.

7. Grade Average Calculator

Objective: Calculate the average grade of a student from a list of grades they enter.

Here are some simpler Python programs that are great for beginners to practice the basics like
input/output, loops, conditionals, and data manipulation:

8. MARKSHEET PROGRAM

1. Odd or Even Number Checker

Objective: Check if the number entered by the user is odd or even.

2. Find the Largest of Two Numbers

Objective: Compare two numbers and print the largest one.

3. Simple Greeting Program


Objective: Ask the user for their name and greet them.

4. Temperature Converter (Celsius to Fahrenheit)

Objective: Convert a temperature from Celsius to Fahrenheit.

5. Multiplication Table (1 to 10)

Objective: Print the multiplication table for a given number.

6. Check if a Number is Positive, Negative, or Zero

Objective: Check if the entered number is positive, negative, or zero.

7. Simple Calculator (Addition Only)

Objective: Add two numbers entered by the user.

8. Count Down from 10 to 1

Objective: Print a countdown from 10 to 1.

9. Simple Interest Calculator


Objective: Calculate simple interest using the formula Simple Interest = (Principal *
Rate * Time) / 100.

10. Check for Vowel or ConsonantObjective: Check if the entered letter is a


vowel or consonant.

11. Sum of Natural Numbers (Up to N)

Objective: Calculate the sum of all natural numbers up to the entered number n.

12. Print Even Numbers Between 1 and N

Objective: Print all even numbers between 1 and the entered number n.

13. Convert Minutes to Hours

Objective: Convert minutes to hours and minutes.

14. Palindrome Checker

Objective: Check if the entered word is a palindrome (reads the same forward and backward).

15. Sum of Digits of a Number

Objective: Calculate the sum of digits of a given number.


16. Prime Number Checker

INTERMEDIATE OR ADVANCED :

Here are 5 Python assignments that go beyond the basics, involving intermediate to advanced
concepts:

1. Build a Simple Calculator (OOP Approach)

●​ Concepts Covered: Object-Oriented Programming, Functions, Exception Handling


●​ Description: Create a calculator that supports basic operations (addition, subtraction,
multiplication, division). Implement a class for the calculator and use functions for each
operation. Include exception handling to manage division by zero errors.
●​ Requirements:
○​ Create a Calculator class with methods for add(), subtract(),
multiply(), and divide().
○​ Use exception handling for invalid inputs and division by zero.
○​ Implement a menu-driven interface to interact with the calculator.

2. Tic-Tac-Toe Game (2-Player)

●​ Concepts Covered: Lists, Loops, Conditionals, Game Logic, Functions


●​ Description: Build a simple command-line Tic-Tac-Toe game where two players can
play alternately. Implement logic to check for winning conditions and draw.
●​ Requirements:
○​ Use a 3x3 grid (list of lists).
○​ Players should enter their moves by specifying row and column numbers.
○​ Implement a function to check if a player has won or if the game is a draw.
○​ The game should end when there is a winner or a draw.

3. Student Grade Management System (with File Handling)

●​ Concepts Covered: File Handling, Lists, Dictionaries, Functions, Input/Output


●​ Description: Create a system that can manage student grades. The program should
allow adding students, viewing all students, editing grades, and saving the data to a file
(e.g., CSV or JSON).
●​ Requirements:
○​ Store student names and their grades in a dictionary.
○​ Implement functions to add new students, edit grades, and display student
information.
○​ Save student data to a file and load it when the program starts.
○​ Allow the user to view a report of all students and their grades.

4. Weather Forecast Program (Using API)

●​ Concepts Covered: Working with APIs, JSON Parsing, External Libraries (Requests),
Error Handling
●​ Description: Create a program that fetches real-time weather data from an open
weather API (like OpenWeatherMap) and displays the current weather for a city entered
by the user.
●​ Requirements:
○​ Use the requests library to interact with an API and fetch weather data.
○​ Parse the JSON response to extract temperature, humidity, weather conditions,
etc.
○​ Allow the user to input a city name and display the current weather information.
○​ Handle errors gracefully (e.g., if the city is not found or the API request fails).

5. Simple Inventory System (CRUD Operations)

●​ Concepts Covered: CRUD Operations, Dictionaries, Loops, Functions, File Handling


●​ Description: Develop an inventory system that allows users to manage products, their
quantities, and prices. Implement basic CRUD (Create, Read, Update, Delete)
operations for managing the inventory.
●​ Requirements:
○​ Use a dictionary to store product data (e.g., product name, quantity, price).
○​ Implement functions for adding, updating, deleting, and viewing products in the
inventory.
○​ Allow the user to display the entire inventory.
○​ Save and load the inventory data from a file (e.g., using JSON or CSV).

These assignments are designed to challenge your understanding of intermediate Python


concepts, including OOP, file handling, API integration, and real-world problem solving.
They will help you build more complex, functional programs that go beyond simple script writing.

Here’s a detailed 12-week plan with daily exercises for consistent practice:

Week 1: Python Basics


Day 1:

●​ Print “Hello, World!”


●​ Write a program to take your name as input and print it.
●​ Explore basic arithmetic operations.

Day 2:

●​ Input two numbers and display their sum, difference, product, and quotient.
●​ Write a program to check if a number is positive, negative, or zero.

Day 3:

●​ Create a program to find the largest of three numbers.


●​ Practice logical operators with simple if-else conditions.

Day 4:

●​ Write a program to calculate the area of a circle.


●​ Explore formatting strings and use f-strings.

Day 5:

●​ Create a simple number guessing game using if-else.


●​ Practice writing comments and organizing code neatly.

Day 6:

●​ Solve 5 problems using loops (e.g., print numbers 1–10, calculate the sum of first N
numbers).

Day 7:

●​ Review and write a program to calculate factorial using loops.

Week 2: Loops and Conditions

Day 1:
●​ Write a program to check if a number is prime.
●​ Practice nested loops with patterns (e.g., a pyramid).

Day 2:

●​ Write a program to find all divisors of a number.


●​ Create a multiplication table for any given number.

Day 3:

●​ Count vowels in a sentence using loops.


●​ Write a program to reverse a number using loops.

Day 4:

●​ Create a program to print Fibonacci numbers up to N.


●​ Explore the break and continue statements in loops.

Day 5:

●​ Write a program to find the GCD and LCM of two numbers.


●​ Solve small problems using loops and conditionals.

Day 6–7:

●​ Work on mini-project: Create a menu-driven program (e.g., calculator or basic unit


converter).

Week 3: Lists

Day 1:

●​ Create a list of 5 numbers and find their sum and average.


●​ Write a program to find the largest and smallest number in a list.

Day 2:

●​ Reverse a list using slicing.


●​ Remove duplicates from a list.

Day 3:

●​ Use list comprehension to create a new list with squares of numbers.


●​ Write a program to find the frequency of each element in a list.

Day 4:

●​ Merge two lists and sort them.


●​ Write a program to split a sentence into words and store them in a list.

Day 5–7:

●​ Mini-project: Create a grocery list manager with features to add, remove, and display
items.

Week 4: Strings and Tuples

Day 1:

●​ Count occurrences of each character in a string.


●​ Reverse a string without using slicing.

Day 2:

●​ Write a program to check if a string is a palindrome.


●​ Explore common string methods like .split(), .join(), .replace().

Day 3:

●​ Create a tuple of 5 numbers and find their sum.


●​ Write a program to check if an element exists in a tuple.

Day 4–7:

●​ Mini-project: Develop a text analyzer that reads a paragraph and counts words, vowels,
and unique words.
Week 5–6: Functions and Modules

Day 1:

●​ Write a function to find the factorial of a number.


●​ Create a function to check if a number is prime.

Day 2:

●​ Write a function to return the largest of three numbers.


●​ Create a program with multiple functions, e.g., a calculator.

Day 3–4:

●​ Explore Python modules: math, random.


●​ Write a program that simulates rolling a die.

Day 5–6:

●​ Explore creating your own modules and importing them.


●​ Mini-project: Create a utility module with frequently used functions.

Week 7: File Handling

Day 1:

●​ Write a program to create and write to a file.


●​ Read the content of a file and display it.

Day 2–3:

●​ Write a program to append data to a file.


●​ Create a program to count words in a file.

Day 4–7:
●​ Mini-project: Develop a student record system with file storage (add, view, and delete
records).

Week 8–9: Object-Oriented Programming (OOP)

Day 1:

●​ Define a simple class and create objects.


●​ Write a class to represent a bank account (methods: deposit, withdraw).

Day 2:

●​ Add constructors and attributes to your class.


●​ Explore inheritance and create subclasses.

Day 3–4:

●​ Write a program to manage library books using OOP concepts.


●​ Create a small project like a vehicle management system.

Week 10–12: Final Project

Suggestions:

●​ Build a budgeting application.


●​ Create a contact management system.
●​ Develop a simple quiz game with OOP and file handling.

LIST

Here are some exercises to help you practice working with lists in Python:
Exercise 1: Create a list of numbers and find the largest and smallest
numbers

●​ Create a list of integers.


●​ Find and print the largest and smallest numbers in the list.

Exercise 2: Reverse a list

●​ Create a list of strings.


●​ Reverse the order of the list without using the reverse() method and print the
reversed list.

Exercise 3: Remove all duplicate items from a list

●​ Create a list with some duplicate items.


●​ Remove the duplicates and print the list without duplicates.

Exercise 4: List sum and average

●​ Create a list of integers.


●​ Calculate and print the sum and average of the numbers in the list.

Exercise 5: Check if a list is empty

●​ Create a list.
●​ Check if the list is empty and print a message saying "The list is empty" or "The list is not
empty."

Exercise 6: List slicing

●​ Create a list of numbers.


●​ Print the first three elements of the list.
●​ Print the last three elements of the list.

Exercise 7: Count occurrences of a specific item

●​ Create a list of mixed data (numbers, strings, etc.).


●​ Count how many times a specific item (for example, a string or number) appears in the
list.
Exercise 8: Find the common elements between two lists

●​ Create two lists with some common elements.


●​ Write a program that finds and prints the common elements between the two lists.

Exercise 9: List sorting

●​ Create a list of integers.


●​ Sort the list in descending order and print the result.

Exercise 10: Remove an element by index

●​ Create a list with some elements.


●​ Remove an element by its index and print the updated list.

Exercise 11: Find the second largest number

●​ Create a list of integers.


●​ Find the second largest number in the list without sorting it.

Exercise 12: Sum of even numbers in a list

●​ Create a list of integers.


●​ Write a program that sums up only the even numbers in the list.

Exercise 13: Convert a string into a list of characters

●​ Take a string from the user.


●​ Convert the string into a list of characters and print the list.

Exercise 14: Merge two lists

●​ Create two lists of equal length.


●​ Merge them into a third list by alternating elements from both lists.

Exercise 15: Create a list of squares

●​ Create a list of numbers from 1 to 10.


●​ Create a new list with the squares of each number in the original list.
Exercise 16: Create a nested list

●​ Create a list that contains other lists (nested lists).


●​ Access and print an item from a nested list.

Exercise 17: List comprehension

●​ Create a list of numbers from 1 to 20.


●​ Using list comprehension, create a new list with only the even numbers.

Exercise 18: Find if an item exists in a list

●​ Create a list of random numbers.


●​ Ask the user for a number and check if that number exists in the list. Print a message
accordingly.

Exercise 19: Remove multiple items from a list

●​ Create a list with multiple elements.


●​ Remove multiple items (for example, remove all occurrences of a specific value) from
the list.

Exercise 20: Sum of digits in a list of numbers

●​ Create a list of numbers.


●​ Calculate the sum of the digits of each number in the list and print the result.

TUPLE

Here are prompts for practicing tuple-related concepts without code:

Tuple Prompts for Practice

1.​ Create and Access​

○​ Create a tuple to store the names of five cities.


○​ Access the second and last city in the tuple.
○​ Attempt to modify the third city.
2.​ Basic Operations​

○​ Combine two tuples of numbers and find their total length.


○​ Reverse a tuple without using loops.
○​ Create a tuple and repeat it three times.
3.​ Membership Check​

○​ Create a tuple of colors. Check if a specific color exists in the tuple.


○​ Try checking for an item that isn’t in the tuple and note the result.
4.​ Nested Tuples​

○​ Create a tuple with nested tuples inside it. Access specific elements within the
nested tuples.
○​ Extract a nested tuple and print its first and last element.
5.​ Tuple Slicing​

○​ Create a tuple of 10 numbers. Slice it to get the first half and the second half.
○​ Extract every third element from a tuple.
6.​ Tuple Unpacking​

○​ Create a tuple with three elements: a name, an age, and a profession.


○​ Unpack the tuple into three variables and print them.
7.​ Methods and Functions​

○​ Count how many times a specific value appears in a tuple.


○​ Find the position of a particular value in the tuple.
○​ Use a function to find the smallest and largest numbers in a tuple.
8.​ Tuple Conversion​

○​ Convert a tuple of strings into a list. Add an element to the list, then convert it
back into a tuple.
○​ Create a tuple of numbers. Convert it to a list, sort it, and then convert it back into
a tuple.
9.​ Tuples as Keys​

○​ Create a dictionary where keys are tuples representing coordinates (x, y), and
values are colors.
○​ Access the color of a specific coordinate using the tuple as a key.
10.​Mathematical Operations​

○​ Create a tuple of integers. Calculate the sum of all elements in the tuple.
○​ Find the difference between the maximum and minimum values in the tuple.
11.​Zipping Tuples​

○​ Pair two tuples: one containing names and another containing ages. Create a list
of tuples representing each name with its corresponding age.
12.​Tuple Comparison​

○​ Compare two tuples element by element to find out which one is larger.
○​ Compare tuples of different lengths and predict the result.
13.​Immutable Property​

○​ Create a tuple and try adding, deleting, or modifying its elements. Observe and
explain the results.
14.​Tuple Nesting Challenge​

○​ Create a tuple of tuples. Each inner tuple should contain a student’s name and
their scores in three subjects.
○​ Access a specific student’s scores and calculate their average.
15.​Real-World Application​

○​ Imagine a system where tuples store a product ID, name, and price. Create
tuples for five products.
○​ Extract all product names and prices from the tuples.

DICTIONARIES

Dictionary Prompts for Practice

1.​ Basic Operations​

○​ Create a dictionary to store the names of five students and their corresponding
grades.
○​ Access the grade of a specific student by their name.
○​ Try to update the grade of a student and add a new student to the dictionary.
2.​ Key and Value Extraction​

○​ Extract and print all keys and values from a dictionary of countries and their
capitals.
○​ Print all items (key-value pairs) from a dictionary.
3.​ Membership Check​
○​ Check if a specific key (e.g., "apple") exists in a dictionary of fruits and their
prices.
○​ Check if a particular value (e.g., 100) exists in the dictionary.
4.​ Iterating Through a Dictionary​

○​ Create a dictionary of students and their scores. Iterate over the dictionary to
print each student’s name and score.
○​ Use a loop to calculate the average score of all students.
5.​ Nested Dictionaries​

○​ Create a dictionary where each key is a product ID, and each value is another
dictionary containing the product’s name, price, and stock quantity.
○​ Access the price of a specific product using its ID.
6.​ Updating Dictionaries​

○​ Create a dictionary with three keys: "morning", "afternoon", and "evening," each
with a corresponding activity as a value.
○​ Update the "morning" activity and add a new key for "night."
7.​ Removing Items​

○​ Remove a key-value pair from a dictionary of countries and their population.


○​ Clear all entries from the dictionary and verify it is empty.
8.​ Counting with Dictionaries​

○​ Write a program to count the frequency of each letter in a given word using a
dictionary.
○​ Create a dictionary to count how many times each color appears in a list of
colors.
9.​ Default Values​

○​ Use the get() method to access values safely from a dictionary of animals and
their habitats.
○​ Attempt to access a non-existent key and provide a default message.
10.​Merging Dictionaries​

○​ Combine two dictionaries: one containing names and another containing ages.
○​ Merge two dictionaries of items and their prices, ensuring no data is lost.
11.​Sorting and Filtering​

○​ Create a dictionary of products and their prices. Sort the dictionary by price
(ascending).
○​ Filter out products with a price below a certain threshold.
12.​Using Tuples as Keys​
○​ Create a dictionary where keys are tuples representing coordinates (x, y), and
values are descriptions of locations.
○​ Access a description using a specific coordinate tuple.
13.​Real-World Application​

○​ Design a dictionary to store a library's book data. Each key should be a book title,
and each value should be the author’s name.
○​ Add, update, and remove books from the dictionary.
14.​Frequency Count​

○​ Create a dictionary to count how many times each word appears in a given
sentence.
○​ Count the frequency of numbers in a list and store the results in a dictionary.
15.​Complex Data Structures​

○​ Design a dictionary where each key is a student’s name, and each value is a
dictionary containing their age, grade, and subjects they study.
○​ Access a specific student’s subjects and update their grade.
16.​Mapping and Transformations​

○​ Create a dictionary mapping numbers (1–5) to their squares.


○​ Transform the dictionary to map numbers to their cubes instead.
17.​Dictionary Comprehension​

○​ Use dictionary comprehension to create a dictionary of numbers (1–10) and their


squares.
○​ Create a dictionary from a list of words, where keys are words and values are
their lengths.
18.​Grouped Data​

○​ Create a dictionary where keys are categories (e.g., "fruits", "vegetables"), and
values are lists of items in those categories.
○​ Add new items to a specific category and remove an item from another category.
19.​Error Handling with Dictionaries​

○​ Try to access a non-existent key without causing a runtime error.


○​ Use pop() to safely remove a key and handle cases where the key doesn’t
exist.
20.​Working with JSON​

○​ Represent a dictionary as a JSON-like structure with nested data.


○​ Convert the dictionary into a format that could be written to a JSON file
(conceptual understanding).
Flowcharts

Here are a few long Python program prompts to practice creating flowcharts:

1. Library Management System

Design a program for a library management system. The system should:

●​ Allow users to register with a unique ID.


●​ Provide options to search for books by title, author, or genre.
●​ Allow users to borrow and return books.
●​ Maintain a log of borrowed books and their due dates.
●​ Show overdue fines for late returns.

2. Restaurant Billing System

Create a program to manage billing at a restaurant. The system should:

●​ Display a menu with items and their prices.


●​ Allow customers to select items and specify quantities.
●​ Calculate the total bill with taxes.
●​ Apply discounts for special offers.
●​ Print an itemized bill with the total.

3. Quiz Game with Score Tracking

Develop a program for a quiz game. The game should:

●​ Load questions and answers from a file.


●​ Ask the user a series of multiple-choice questions.
●​ Keep track of correct and incorrect answers.
●​ Display the score and performance at the end.
●​ Allow the user to restart the quiz.

4. Student Grading System

Design a program for managing student grades. The system should:

●​ Input student names, IDs, and marks for multiple subjects.


●​ Calculate the total marks, percentage, and grade (A, B, C, etc.).
●​ Display student results in a tabular format.
●​ Generate a list of top-performing students.

5. ATM Simulator

Build an ATM simulator with the following features:

●​ Allow users to log in using a PIN.


●​ Provide options to check balance, deposit, withdraw, or transfer money.
●​ Maintain a log of transactions.
●​ Ensure withdrawal limits are respected.
●​ Logout after a period of inactivity.

6. Inventory Management System

Develop a system to manage inventory for a small store. The system should:

●​ Allow the user to add, remove, and update product details (name, price, quantity).
●​ Track stock levels and generate alerts for low stock.
●​ Generate reports of all inventory items with their current quantities and values.
●​ Save inventory data to a file for persistence.

7. Employee Payroll System


Create a payroll system with these features:

●​ Allow HR to input employee details (name, ID, hourly wage).


●​ Calculate salaries based on hours worked.
●​ Deduct taxes and display net pay.
●​ Print a payslip for each employee.
●​ Save salary records for future reference.

### Comprehensive List Functions Exercise

Create a program that manages a list of items in a **shopping cart**. The program should
provide the user with the following options:

---

#### **Instructions:**

1. **Add an item** to the shopping cart.

- Prompt the user to enter the name of the item.

- Append the item to the list.

2. **Remove an item** from the shopping cart.

- Prompt the user to enter the name of the item to remove.

- Remove the item if it exists. Handle cases where the item is not in the cart.

3. **Display all items** in the cart.


- Show the list of items in a neat format.

4. **Count the total items** in the cart.

- Display the total number of items.

5. **Find a specific item** in the cart.

- Prompt the user for an item to search for. Indicate whether the item is in the cart or not.

6. **Sort the cart items** alphabetically.

- Display the sorted list.

7. **Clear all items** in the cart.

- Empty the shopping cart completely.

8. **Exit the program.**

---

#### **Additional Challenges (Optional):**

- Prevent duplicate items from being added to the cart.

- Save the cart to a file and load it when the program starts.

- Allow the user to update an item in the cart.

---
#### **What You'll Practice:**

- Adding (`append`)

- Removing (`remove`, `pop`, or `del`)

- Searching (`in`, `index`)

- Counting (`len`, `count`)

- Sorting (`sort`, `sorted`)

- Clearing (`clear`)

- Handling user input and exceptions.

Here are some beginner exercises that use only strings manipulation, operators, and if-else
statements:

1. Palindrome Checker

Write a program that checks if a given word is a palindrome (a word that reads the same
backward as forward).

2. String Length Comparison

Take two strings as input and compare their lengths:

●​ Print which string is longer.


●​ If they have the same length, print a message saying so.
3. Password Strength Checker

Ask the user for a password and check:

●​ If the password length is at least 8 characters, print "Strong password."


●​ Otherwise, print "Weak password."

4. Vowel Counter

Take a sentence as input and count how many vowels (a, e, i, o, u) it contains.

5. Case Converter

Take a sentence as input:

●​ Convert it to all uppercase if the sentence starts with a lowercase letter.


●​ Convert it to all lowercase if the sentence starts with an uppercase letter.

6. String Contains Check

Take a word and a sentence as input:

●​ Check if the word is present in the sentence.


●​ Print "Word found!" or "Word not found!"

7. Simple Calculator

Take a mathematical expression as input (e.g., 5 + 3 or 8 - 2):

●​ Parse the numbers and the operator.


●​ Perform the calculation and print the result.
8. Username Validation

Take a username as input:

●​ If it contains spaces, print "Invalid username."


●​ Otherwise, print "Username is valid."

9. String Reversal

Ask the user to input a word and print its reverse.

10. Letter Case Counter

Take a sentence as input and count:

●​ How many uppercase letters it has.


●​ How many lowercase letters it has.

11. Character Repetition

Take a word and a character as input:

●​ Count how many times the character appears in the word.


●​ Print the result.

12. First and Last Character Match

Take a word as input:


●​ Check if the first and last characters of the word are the same.
●​ Print "Match" or "No match."

13. Basic Username Suggestion

Ask the user for their first name and last name:

●​ Combine the first three letters of the first name with the last three letters of the last
name.
●​ Print the suggested username.

14. Sentence Splitter

Take a sentence as input:

●​ Split it into individual words (you can use .split()).


●​ Print each word on a new line.

15. String Comparison

Take two strings as input:

●​ Check if they are equal (case-sensitive).


●​ Print "Strings are equal" or "Strings are not equal."

16. Count Words in a Sentence

Take a sentence as input:

●​ Count how many words it contains (words are separated by spaces).


●​ Print the result.
17. Check Start and End

Take a word and a sentence as input:

●​ Check if the sentence starts with the given word or ends with the given word.
●​ Print the appropriate message.

18. Substring Replacement

Take a sentence, a word to replace, and a new word as input:

●​ Replace all occurrences of the first word with the new word.
●​ Print the modified sentence.

19. Simple Grading System

Ask for a student's marks:

●​ If marks are 90 or above, print "Grade: A."


●​ If marks are 75-89, print "Grade: B."
●​ If marks are 50-74, print "Grade: C."
●​ Otherwise, print "Grade: F."

20. Character Distance

Take two characters as input:

●​ Find the ASCII values of both characters.


●​ Calculate and print the difference between their ASCII values.
Here are more exercises to practice similar concepts involving lists, dictionaries, and
conditionals in Python. These exercises focus on improving your skills in managing collections
and displaying summaries.

1. Book Borrowing System

Write a program to manage a library system where users can borrow books. The program
should:

1.​ Allow the user to input book titles to borrow (store in a list).
2.​ Display a summary showing the count of each borrowed book.
3.​ If no books are borrowed, display "No books borrowed."

2. Inventory Management

Write a program to manage an inventory system:

1.​ Start with an inventory dictionary, e.g., inventory = {"Apples": 10,


"Bananas": 5, "Oranges": 8}.
2.​ Allow the user to add items to the cart.
3.​ Deduct the added items from the inventory.
4.​ Display the updated inventory and notify if an item is out of stock.

3. Classroom Attendance Tracker

Write a program to track student attendance:

1.​ Allow the user to input student names (store in a list).


2.​ Display a summary of attendance, showing the count of each student's name.
3.​ If no names are entered, display "No attendance recorded."

4. Polling System
Write a program for a simple polling system:

1.​ Allow users to vote for their favorite fruits from a predefined list (e.g., "Apple," "Banana,"
"Orange").
2.​ Store votes in a list.
3.​ At the end of polling, display the total votes for each fruit.

5. Grocery Price Calculator

Write a program that:

1.​ Starts with a dictionary of grocery items and their prices (e.g., {"Apple": 2.5,
"Banana": 1.2, "Orange": 1.8}).
2.​ Allows the user to input items to add to their cart.
3.​ Calculates the total price of all items in the cart.
4.​ If the cart is empty, display "Your cart is empty."

6. Expense Tracker

Write a program to track daily expenses:

1.​ Allow the user to input categories and amounts (e.g., "Food 50", "Transport 30").
2.​ Store expenses in a dictionary where keys are categories and values are total amounts.
3.​ Display a summary of expenses for each category.

7. Gradebook Management

Write a program to manage grades for students:

1.​ Allow the user to input student names and their scores.
2.​ Store this data in a dictionary, where names are keys and scores are values.
3.​ Display the average, highest, and lowest scores at the end.
8. Word Frequency Counter

Write a program that:

1.​ Takes a paragraph of text as input.


2.​ Counts the frequency of each word.
3.​ Displays a summary showing each word and its frequency.

9. Quiz Scorer

Write a program for a quiz scoring system:

1.​ Define a dictionary of questions and answers.


2.​ Allow the user to answer each question.
3.​ Display the total score and which questions were answered correctly.

10. To-Do List Manager

Write a program to manage a to-do list:

1.​ Allow the user to add tasks to the list.


2.​ Mark tasks as complete.
3.​ Display the current list of tasks, showing which ones are complete and which are
pending.

You might also like