This repository contains 5 small Python projects made while learning Python programming and basic DSA concepts.
The purpose of making these projects was not just to write code, but to understand how different programming concepts work together in a complete program.
- ATM Simulation
- Car Drive Simulation
- Login System
- Student Marks Analyzer
- Number Analyzer
Before understanding these projects, it is important to understand some basic Python concepts used in them.
Python is a programming language with simple and readable syntax. A Python program is made by writing instructions that tell the computer what to do.
For example:
name = input("Enter your name: ")
print("Hello", name)Here the program does two things:
input()asks the user for information.- The entered value is stored in
name. print()displays the result.
So, the basic flow is:
User gives input
|
v
Program processes the input
|
v
Program gives output
The same basic idea is used in all the projects in this repository.
A variable is a name used to store some value in a program.
For example:
name = "Isha"
marks = 85Here:
nameis a variable."Isha"is the value stored in it.marksis another variable.85is its value.
We use variables because programs need to remember information while they are running.
In the Car Drive Simulation:
speed = 50
fuel = 20The program needs to remember the current speed and fuel, so these values are stored in variables.
A data type tells Python what kind of value we are working with.
Some common types used in these projects are:
Used for text.
name = "Isha"name contains a string.
Strings are used for things like:
- Student names
- Usernames
- Passwords
- Account holder names
Used for whole numbers.
age = 20Used for numbers that can contain decimal values.
marks = 85.5
balance = 2500.50This is useful for:
- Marks
- Money
- Fuel
- Distance
A Boolean has only two values:
True
FalseFor example, in the Car Drive Simulation:
engine = FalseThis means the engine is currently OFF.
When the engine starts:
engine = TrueNow the engine is ON.
input() is used when we want the user to enter something.
Example:
name = input("Enter your name: ")The program waits for the user to type something.
If the user enters:
Isha
then name stores "Isha".
input() normally gives the entered value as a string.
For example:
marks = input("Enter marks: ")Even if the user enters 85, Python initially treats it as text.
If we want to use it as a number, we need type conversion.
Type conversion means changing a value from one data type to another.
For example:
marks = int(input("Enter marks: "))Here:
input()takes the value.int()converts it into an integer.- The result is stored in
marks.
Common conversions used in these projects:
int()- converts a value into an integer.float()- converts a value into a decimal number.str()- converts a value into a string.
amount = float(input("Enter amount: "))float() is useful in the ATM project because an amount can contain decimal values.
print() is used to display information on the screen.
Example:
print("Hello", name)The program can use print() to show:
- Results
- Error messages
- Menu options
- Account information
- Student marks
- Car status
Operators are symbols used to perform operations on values.
Some operators used in these projects are:
| Operator | Meaning | Example |
|---|---|---|
+ |
Addition | 10 + 5 |
- |
Subtraction | 10 - 5 |
* |
Multiplication | 10 * 5 |
/ |
Division | 10 / 5 |
% |
Remainder | 10 % 3 |
The Car Drive Simulation uses:
Distance = Speed x Time
In Python:
distance = speed * timeThe Number Analyzer uses addition to calculate the total of numbers.
The % operator gives the remainder after division.
For example:
10 % 2The result is 0.
This is useful for checking whether a number is even or odd.
number % 2 == 0If the remainder is 0, the number is even.
Example:
10 % 2 = 0 -> Even
15 % 2 = 1 -> Odd
This logic is used in the Number Analyzer.
Conditions allow a program to make decisions.
For example:
if marks >= 50:
print("Pass")
else:
print("Fail")The program checks the condition:
Are marks greater than or equal to 50?
- If yes, it prints
Pass. - Otherwise, it prints
Fail.
Conditions are used throughout these projects.
Examples:
- Checking whether the ATM balance is enough.
- Checking whether the engine is ON.
- Checking whether marks are valid.
- Checking whether the login details are correct.
When there are multiple possible conditions, we can use if, elif and else.
Example from the Student Marks Analyzer:
if marks >= 90:
grade = "A+"
elif marks >= 80:
grade = "A"
elif marks >= 70:
grade = "B"
else:
grade = "F"Python checks the conditions from top to bottom.
The first condition that becomes true is used.
This is useful when there are multiple possibilities.
A loop is used when we want to repeat some instructions.
Two main loops are used in these projects:
forloopwhileloop
A for loop is generally used when we want to process items one by one.
Example:
numbers = [10, 20, 30]
for number in numbers:
print(number)The loop works like this:
- Take
10. - Run the code.
- Take
20. - Run the code.
- Take
30. - Run the code.
- Stop after all items are processed.
The same idea is used in the Student Marks Analyzer to process every student and in the Number Analyzer to process every number.
A while loop keeps running as long as a condition is true.
Example:
while attempts > 0:
# login codeIn the Login System, a while loop is useful because the user can try to login more than once.
It is also used when we need to keep asking the user for valid input.
For example, if a PIN is not 4 digits, the program can ask again.
A function is a block of code created for a particular task.
Example:
def find_largest(numbers):
# codeHere:
defis used to create a function.find_largestis the function name.numbersis the input given to the function.
Functions are useful because a large program can be divided into smaller parts.
For example, instead of writing the complete ATM program in one place, different tasks are separated into functions:
create_account()login()deposit_money()withdraw_money()check_balance()change_pin()
This makes the code easier to read and understand.
A function can receive information from outside.
Example:
def find_largest(numbers):Here, numbers is a parameter.
When we call:
find_largest(my_numbers)my_numbers is the argument passed to the function.
This allows the same function to work with different data.
A function can send a result back using return.
Example:
def calculate_sum(numbers):
total = 0
for number in numbers:
total += number
return totalThe function calculates the sum and returns the result.
Then the returned value can be stored:
total = calculate_sum(numbers)This is used in the Number Analyzer and other projects.
A list is a data structure used to store multiple values together.
Example:
numbers = [10, 20, 30, 40]Instead of creating separate variables:
number1 = 10
number2 = 20
number3 = 30
number4 = 40we can store them together in one list.
Lists are useful in these projects for:
- Storing numbers.
- Storing students.
- Storing transactions.
Each item in a Python list has a position called an index.
Python starts indexing from 0.
Example:
numbers = [10, 20, 30]The positions are:
10 -> index 0
20 -> index 1
30 -> index 2
So:
numbers[0]gives:
10
This is useful when we need to access a particular item.
append() is used to add a new item to the end of a list.
Example:
numbers = [10, 20]
numbers.append(30)Now the list becomes:
[10, 20, 30]
In the ATM project, append() is used to add new transactions to the transaction list.
In the Student Marks Analyzer, it is used to add each student to the student list.
len() tells us how many items are present.
Example:
numbers = [10, 20, 30]len(numbers)gives:
3
In the Student Marks Analyzer, len() helps calculate the number of students.
For example:
Average = Total Marks / Number of Students
The number of students can be found using:
len(students)A dictionary stores information using key-value pairs.
Example:
student = {
"name": "Isha",
"marks": 85,
"grade": "A"
}Here:
"name"is a key."Isha"is its value."marks"is a key.85is its value."grade"is a key."A"is its value.
A dictionary is useful when different pieces of information belong to the same object.
For example, a student has:
- Name
- Marks
- Grade
So we can store all of them together.
Dictionaries are also used for:
- ATM account information.
- Car information.
- Login information.
We can access a dictionary value using its key.
Example:
student["marks"]This gives:
85
In the ATM project:
data["balance"]is used to access the current account balance.
Sometimes we need to store many objects, where each object has different information.
For example, the Student Marks Analyzer has many students.
One student can be:
{
"name": "Isha",
"marks": 85,
"grade": "A"
}Many students can be stored inside a list:
students = [
{
"name": "Isha",
"marks": 85,
"grade": "A"
},
{
"name": "Rahul",
"marks": 72,
"grade": "B"
}
]This combines two concepts:
- List -> stores multiple students.
- Dictionary -> stores information about one student.
Input validation means checking whether the information entered by the user is acceptable.
This is important because users can enter incorrect data.
Examples from these projects:
- PIN must contain exactly 4 digits.
- Deposit cannot be negative.
- Withdrawal cannot be greater than balance.
- Marks must be between 0 and 100.
- Student name cannot be empty.
- Username cannot be empty.
- Password must contain at least 4 characters.
- Acceleration must be positive.
- Fuel amount must be positive.
- Speed cannot go beyond the maximum limit.
Validation prevents invalid values from being used in the program.
Sometimes a program can get an unexpected input and produce an error.
For example:
amount = float(input("Enter amount: "))If the user enters:
hello
Python cannot convert "hello" into a float.
This can cause a ValueError.
To handle this, we can use:
try:
amount = float(input("Enter amount: "))
except ValueError:
print("Please enter a valid amount.")This means:
trycontains the code that may produce an error.excepthandles the error.- The program can show a proper message instead of stopping suddenly.
This is used in several projects for numeric input.
A menu-driven program gives the user multiple choices.
For example, the ATM menu contains:
1. Check Balance
2. Deposit Money
3. Withdraw Money
4. Mini Statement
5. Last Transaction
6. Change PIN
7. Account Details
8. Logout
The user enters a choice.
The program checks the choice using if-elif-else and calls the required function.
This type of structure is used in:
- ATM Simulation
- Car Drive Simulation
It makes the program easier for the user to operate.
File handling means reading data from a file or writing data into a file.
Normally, variables lose their values when the program closes.
For example:
balance = 5000If the program closes, this variable no longer exists.
To keep data for later, we can save it in a file.
The ATM project uses a JSON file for this purpose.
JSON stands for JavaScript Object Notation.
It is a common format used for storing structured data.
The ATM project uses:
atm_data.json
to store information such as:
- Account holder name
- Account number
- PIN
- Balance
- Transactions
Python provides the json module to work with JSON files.
The program can:
- Read existing data.
- Update the data.
- Save the updated data.
This means the ATM data can remain available even after the program is closed.
The ATM project uses Python's datetime module.
It is used to get the current date and time.
For example, when a transaction happens, the program stores its date and time.
A transaction can contain information like:
Deposit
Amount: 500
Date: 14-09-2026 18:30:00
This makes the mini statement more useful.
The projects in this repository are beginner-level projects, but they also use some basic DSA ideas.
A data structure is a way of organizing and storing data so that it can be used efficiently.
The main data structures used here are:
- Lists
- Dictionaries
Traversal means visiting elements one by one.
For example:
numbers = [10, 20, 30]
for number in numbers:
print(number)The program visits:
10
20
30
one by one.
Traversal is used in:
- Number Analyzer
- Student Marks Analyzer
- ATM transaction processing
Searching means checking data to find something we need.
For example, in the Number Analyzer we need to find the largest number.
Suppose:
numbers = [10, 25, 15, 40, 20]
The program can do this:
- Start with
10as the largest. - Compare
25with10. 25is larger, so largest becomes25.- Compare
15with25. 15is smaller, so keep25.- Compare
40with25. 40is larger, so largest becomes40.- Compare
20with40. 20is smaller.- Final largest value is
40.
This is a simple way of searching through a list.
The same idea can be used to find the smallest number.
Suppose:
[10, 25, 15, 5, 20]
Steps:
- Start with
10as the smallest. - Compare
25. 25is not smaller.- Compare
15. 15is not smaller.- Compare
5. 5is smaller, so update the smallest value.- Continue checking the remaining numbers.
- Final smallest value is
5.
Counting means keeping track of how many times something happens.
For example, the Number Analyzer counts even and odd numbers.
We start with:
even_count = 0
odd_count = 0Then every number is checked.
If the number is even:
even_count += 1If it is odd:
odd_count += 1At the end, we know how many even and odd numbers were entered.
File: atm_simulation.py
The ATM Simulation is a menu-driven program that behaves like a simple ATM.
- Account creation
- 4-digit PIN
- PIN confirmation
- Account number generation
- Login
- 3 login attempts
- Balance checking
- Deposit
- Withdrawal
- Mini statement
- Last transaction
- PIN change
- Account details
- Logout
- JSON data storage
When no account is available, the program asks for:
- Account holder name
- 4-digit PIN
- PIN confirmation
- Initial deposit
The program validates the PIN before creating the account.
It also generates an account number and stores the account information.
The user enters the PIN.
The program compares the entered PIN with the stored PIN.
There are 3 attempts.
If the correct PIN is entered:
Login successful
If all attempts are incorrect, access is blocked for that session.
Suppose the current balance is:
Rs. 5000
and the user deposits:
Rs. 1000
The program performs:
5000 + 1000 = 6000
The new balance becomes:
Rs. 6000
The transaction is also added to the transaction list.
Suppose:
Balance = Rs. 6000
Withdrawal = Rs. 2000
The program checks whether:
2000 <= 6000
Since enough balance is available:
6000 - 2000 = 4000
The new balance becomes Rs. 4000.
If the requested amount is greater than the balance, the withdrawal is rejected.
Transactions are stored in a list.
The program displays the latest 5 transactions.
Each transaction contains:
- Type
- Amount
- Date and time
The program first checks the current PIN.
Only after the current PIN is correct can the user create a new PIN.
The new PIN is also checked to make sure it contains exactly 4 digits.
- Load existing data.
- Check whether an account exists.
- If no account exists, ask for account holder name.
- Ask for a 4-digit PIN.
- Check whether the PIN contains exactly 4 digits.
- Ask the user to confirm the PIN.
- Ask for the initial deposit.
- Validate the deposit.
- Generate an account number.
- Store the account details.
- Save the data in the JSON file.
- Set the number of attempts to 3.
- Ask for the PIN.
- Compare it with the stored PIN.
- If correct, allow access.
- If incorrect, reduce the number of attempts.
- Continue until login succeeds or attempts become 0.
- Block access for the session if all attempts fail.
- Take the withdrawal amount.
- Check whether it is a valid number.
- Check whether the amount is positive.
- Compare the amount with the current balance.
- If enough balance is available, subtract the amount.
- Store the transaction.
- Save the updated data.
File: car_drive_simulation.py
This project simulates some basic actions of a car.
The program keeps four main values:
Speed
Distance
Fuel
Engine status
Speed = 0 km/h
Distance = 0 km
Fuel = 20 litres
Engine = OFF
If the engine is OFF, the program changes its value to ON.
If the engine is already ON, it tells the user that it is already running.
The user enters an acceleration value.
The program:
- Checks whether the engine is ON.
- Checks whether fuel is available.
- Takes the acceleration value.
- Increases the speed.
- Makes sure the speed does not go above 120 km/h.
- Reduces a small amount of fuel.
The user enters a braking value.
The program subtracts this value from the current speed.
If the speed becomes negative, it is set to 0.
A car cannot have negative speed.
The user enters the driving time.
The program calculates distance using:
Distance = Speed x Time
For example:
Speed = 40 km/h
Time = 2 hours
Distance = 40 x 2
= 80 km
Fuel is also reduced according to the distance travelled.
The user enters the amount of fuel to add.
The program:
- Checks that the amount is positive.
- Adds the fuel.
- Makes sure total fuel does not exceed 50 litres.
- Create the car dictionary.
- Set speed to 0.
- Set distance to 0.
- Set fuel to 20 litres.
- Set engine to OFF.
- Display the menu.
- Take the user's choice.
- Check whether the selected operation is allowed.
- Update the car values.
- Display the updated information.
- Repeat until the user chooses Exit.
File: login_system.py
This project demonstrates the basic logic behind a login system.
The user first creates an account.
The program stores:
- Username
- Password
Then the user tries to login using those details.
The program checks:
- Username should not be empty.
- Password should contain at least 4 characters.
After successful account creation, the user is asked to login.
The user enters:
- Username
- Password
The program compares both values with the stored information.
Both must match for successful login.
Stored information:
Username = Isha
Password = python123
If the user enters:
Username = Isha
Password = wrong
the login fails because the password does not match.
The program allows 3 attempts.
- Ask the user to create a username.
- Check whether the username is empty.
- Ask the user to create a password.
- Check the password length.
- Store both values in a dictionary.
- Set login attempts to 3.
- Ask for username and password.
- Compare them with stored values.
- If both match, login is successful.
- Otherwise, decrease the attempt count.
- Continue until login succeeds or attempts become 0.
- Block login for the current session after all failed attempts.
File: student_marks_analyzer.py
This project takes marks of multiple students and analyzes their basic performance.
For each student, the program stores:
- Name
- Marks
- Grade
This information is stored using a dictionary.
Multiple student dictionaries are stored inside a list.
Marks must be between:
0 and 100
If the user enters:
105
the program does not accept it.
The user is asked to enter the marks again.
The program checks the marks using conditions.
90 - 100 -> A+
80 - 89 -> A
70 - 79 -> B
60 - 69 -> C
50 - 59 -> D
Below 50 -> F
The program considers:
Marks >= 50 -> Pass
Marks < 50 -> Fail
If marks are 80 or above, the program also displays:
Keep it up! Great performance.
The program first calculates total marks.
Then:
Average = Total Marks / Number of Students
For example:
Marks = 80, 70, 90
Total = 80 + 70 + 90
= 240
Average = 240 / 3
= 80
The program compares students one by one.
It starts with the first student as the highest scorer.
If another student has higher marks, that student becomes the new highest scorer.
This continues until all students have been checked.
- Ask for the number of students.
- Create an empty student list.
- Take the name of each student.
- Validate that the name is not empty.
- Take the marks.
- Check that marks are between 0 and 100.
- Calculate the grade.
- Create a dictionary for the student.
- Add the dictionary to the student list.
- Calculate total marks.
- Calculate average marks.
- Compare student marks to find the highest scorer.
- Display every student's result.
- Display the class summary.
File: number_analyzer.py
The Number Analyzer takes multiple numbers from the user and performs different operations.
- Sum
- Subtraction
- Average
- Largest number
- Smallest number
- Even count
- Odd count
First, an empty list is created:
numbers = []Every number entered by the user is added using:
numbers.append(number)For example, if the user enters:
10
20
15
5
the list becomes:
[10, 20, 15, 5]
The program starts with:
total = 0Then it visits every number and adds it.
0 + 10 = 10
10 + 20 = 30
30 + 15 = 45
45 + 5 = 50
Final sum:
50
The program starts with the first number.
For:
10, 20, 15, 5
it performs:
10 - 20 - 15 - 5
The result is calculated step by step.
The program uses:
Average = Sum / Number of Values
For:
10, 20, 15, 5
Sum = 50
Number of values = 4
Average = 50 / 4
= 12.5
The program starts with the first number as the largest.
Then it compares every other number with it.
This is a simple traversal and searching logic.
The same method is used for the smallest number.
Every number is checked using the modulus operator.
number % 2 == 0If the remainder is 0, even_count is increased.
Otherwise, odd_count is increased.
- Ask how many numbers the user wants to enter.
- Create an empty list.
- Take each number from the user.
- Add every number to the list.
- Calculate the sum by traversing the list.
- Calculate subtraction.
- Calculate the average.
- Take the first number as the largest.
- Compare every remaining number with the largest.
- Update the largest when a bigger value is found.
- Repeat the process to find the smallest value.
- Check every number for even or odd.
- Increase the correct counter.
- Display all results.
The projects are designed to handle common incorrect inputs.
Examples:
If the program expects:
Enter marks:
and the user enters:
abc
the program handles the error using try-except.
If the user enters:
120
the Student Marks Analyzer rejects it because marks must be between 0 and 100.
If the user enters:
123
the ATM rejects it because the PIN must contain exactly 4 digits.
If the user has:
Balance = Rs. 1000
and tries to withdraw:
Rs. 1500
the program rejects the withdrawal because the balance is not enough.
The Car Drive Simulation checks conditions such as:
- Engine must be ON before driving.
- Fuel must be available.
- Speed cannot become negative.
- Fuel cannot exceed the tank capacity.
The important part of these projects is that concepts are not used separately. They work together.
For example, in the Student Marks Analyzer:
Input
|
v
Variable
|
v
Validation
|
v
Dictionary
|
v
List
|
v
Loop
|
v
Condition
|
v
Calculation
|
v
Output
Similarly, the ATM project combines:
Functions
+
Dictionary
+
List
+
Conditions
+
Loops
+
File Handling
+
JSON
+
Exception Handling
This is how basic programming concepts come together to make a complete program.
Install Python on the computer.
Open this repository in VS Code.
Open the project folder.
Select any .py file.
Run the file using the Run button or terminal.
For example:
python number_analyzer.pyOther projects can be run in the same way:
python atm_simulation.py
python car_drive_simulation.py
python login_system.py
python student_marks_analyzer.pyThe ATM project creates a local file named:
atm_data.json
It is used to store:
- Account holder information
- Account number
- PIN
- Balance
- Transactions
The file is included in .gitignore.
This means the local test data file is not pushed to GitHub.
While making these projects, I practiced:
- Variables
- Data types
- Input and output
- Type conversion
- Operators
- Conditions
- Loops
- Functions
- Lists
- Dictionaries
- String handling
- Input validation
- Searching
- Traversal
- Counting
- Calculations
- Menu-based logic
- Breaking a problem into smaller functions
- File handling
- JSON
- Reading and writing data
- Date and time
- Lists
- Traversal
- Searching
- Counting
- Finding maximum and minimum values
- VS Code
- Git
- GitHub
These are beginner-level projects, so there are many things that can be improved later.
Some possible improvements are:
- Add a graphical user interface.
- Add database support.
- Improve login security.
- Add more ATM features.
- Add more car simulation features.
- Add more student analysis options.
- Add more DSA-based mini projects.
- Improve the overall user interface of the programs.
Isha Gupta
Python and DSA Practice Projects
The following screenshots show sample outputs from the Python programs when they are executed in the terminal.
The screenshot shows the ATM account setup, login, and menu-based operations.
The screenshot shows the car simulation with engine, speed, fuel, and driving operations.
The screenshot shows account creation and successful login using the created username and password.
The screenshots show student marks, grades, pass/fail status, and class summary.
The screenshot shows the calculated sum, subtraction, average, largest number, smallest number, and even/odd counts.





