0% found this document useful (0 votes)
6 views30 pages

Python Programs for Real-Life Problems

The document outlines various Python programming experiments aimed at solving real-life and scientific problems using algorithms and code implementations. It covers topics such as electricity billing, retail billing, sine series generation, and basic operations like swapping values, calculating distances, and generating number patterns. Each experiment includes algorithms, sample code, and expected outputs, demonstrating the application of Python in technical scenarios.

Uploaded by

oviya vetri
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)
6 views30 pages

Python Programs for Real-Life Problems

The document outlines various Python programming experiments aimed at solving real-life and scientific problems using algorithms and code implementations. It covers topics such as electricity billing, retail billing, sine series generation, and basic operations like swapping values, calculating distances, and generating number patterns. Each experiment includes algorithms, sample code, and expected outputs, demonstrating the application of Python in technical scenarios.

Uploaded by

oviya vetri
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

EXPERIMENT 1

Identify and solve simple real-life/scientific/technical problems (Electricity Billing,


Retail shop billing, Sin series, etc.).

Aim:

To develop Python programs to solve simple real-life or scientific problems such as


electricity billing, retail billing, or generating a sine series.

a) Electricity Billing Program

Algorithm:

1. Start the program


2. Read the number of electricity units consumed from the user
3. If units ≤ 100, calculate bill = units × ₹1.5
4. Else if units ≤ 200, calculate bill = ₹150 + (units − 100) × ₹2.5
5. Else calculate bill = ₹150 + ₹250 + (units − 200) × ₹3.5
6. Display the total electricity bill
7. Stop the program

Program:
units = int(input("Enter units consumed: "))
if units <= 100:
bill = units * 1.5
elif units <= 200:
bill = 100 * 1.5 + (units - 100) * 2.5
else:
bill = 100 * 1.5 + 100 * 2.5 + (units - 200) * 3.5
print("Total Electricity Bill: ₹", bill)

Sample Output:
Input: 250
Output: Total Electricity Bill: ₹575.0

b) Retail Billing System

Algorithm:

1. Start the program


2. Initialize total_amount = 0 and an empty list for items
3. Read number of items from user
4. For each item:
o Read item name, quantity, and price
o Calculate item_total = quantity × price
o Add item details to the list
o Add item_total to total_amount
5. Calculate GST = total_amount × 0.05
6. Calculate grand_total = total_amount + GST
7. Display the bill summary in table format
8. Stop the program
Program:

print("====== RETAIL BILLING SYSTEM ======\n")

items = []
total_amount = 0
n = int(input("Enter number of items: "))

for i in range(n):
print(f"\nItem {i+1}")
name = input("Enter item name: ")
qty = int(input("Enter quantity: "))
price = float(input("Enter price per unit: "))

item_total = qty * price


total_amount += item_total

[Link]([name, qty, price, item_total])

# GST calculation
gst_rate = 0.05 # 5% GST
gst_amount = total_amount * gst_rate
grand_total = total_amount + gst_amount

print("\n====== BILL SUMMARY ======")


print("{:<15} {:<10} {:<10} {:<10}".format("Item", "Qty", "Price", "Total"))
print("-" * 50)

for item in items:


print("{:<15} {:<10} {:<10} {:<10}".format(item[0], item[1], item[2], item[3]))

print("-" * 50)
print(f"Sub Total : ₹ {total_amount:.2f}")
print(f"GST (5%) : ₹ {gst_amount:.2f}")
print(f"Grand Total : ₹ {grand_total:.2f}")

print("\nThank you for shopping with us!")

Sample Output:

====== RETAIL BILLING SYSTEM ======

Enter number of items: 2

Item 1
Enter item name: Soap
Enter quantity: 4
Enter price per unit:25
Item 2
Enter item name: Milk
Enter quantity: 2
Enter price per unit: 30

====== BILL SUMMARY ======


Item Qty Price Total

Soap 4 25.0 100.0


Milk 2 30.0 60.0

Sub Total : ₹ 160.00


GST (5%) : ₹ 8.00
Grand Total : ₹ 168.00

Thank you for shopping with us!

c) Generating a sine series

Algorithm:

1. Start the program


2. Import the math module
3. Read angle (in degrees) and number of terms from the user
4. Convert degrees into radians using formula:
radians = degree × π / 180
5. Initialize variables: sine = 0 and sign = 1
6. Repeat for n = 1 to required terms with step of 2:
o Compute factorial of n
o Compute term = (radiansⁿ / factorial(n))
o Add or subtract term from sine based on sign
o Reverse the sign (-1 multiplier)
7. Display calculated sine value and compare with [Link]()
8. Stop the program

Program:

import math

# Function to calculate factorial


def factorial(n):
fact = 1
for i in range(1, n + 1):
fact *= i
return fact
# Function to calculate sine using series
def sine_series(x, terms):
sine = 0
sign = 1 # controls +, -

for n in range(1, 2 * terms, 2):


term = (x ** n) / factorial(n)
sine += sign * term
sign *= -1
return sine

# Main program
x = float(input("Enter angle in degrees: "))
terms = int(input("Enter number of terms: "))

# Convert degrees to radians


radians = [Link](x)

# Calculate sine
result = sine_series(radians, terms)

print(f"\nSine({x}) using {terms} terms = {result}")


print(f"Math library value = {[Link](radians)}")

Sample Output

Enter angle in degrees: 30


Enter number of terms: 5

Sine(30.0) using 5 terms = 0.4999999918690232


Math library value = 0.5

Result:

Thus the above programs are successfully verified


EXPERIMENT 2
Python programming using simple statements and expressions (exchange the values
of two variables, circulate values of n variables, distance between two points).

Aim: To implement Python programs using simple statements and expressions.

a) Swap two numbers

Algorithm:

1. Start the program


2. Read two numbers a and b from the user
3. Exchange the values of a and b using assignment statement:
a, b = b, a
4. Display the swapped values of a and b
5. Stop the program

Program:
a = int(input("Enter first number: "))
b = int(input("Enter second number: "))
a, b = b, a
print("After swapping: a =", a, "b =", b)

Sample Output:
Input: a=5, b=10
Output: After swapping: a=10 b=5

b) Circulate Values Of N Variables

Algorithm:

1. Start the program


2. Read the number of variables (n)
3. Initialize an empty list to store values
4. Read n values from the user and store them in the list
5. Display the list before circulation
6. Store the last element of the list in a temporary variable
7. Shift elements to the right by one position
8. Place the last element into the first position
9. Display the list after circulation
10. Stop the program

Program:

n = int(input("Enter number of variables: "))

values = []
for i in range(n):
val = input(f"Enter value {i+1}: ")
[Link](val)
print(“\nBefore circulation:”,values)
# Circulate values (right shift)
last = values[-1]
for i in range(n-1, 0, -1):
values[i] = values[i-1]
values[0] = last

print("After circulation :", values)

Sample Output
Enter number of variables: 4
Enter value 1: A
Enter value 2: B
Enter value 3: C
Enter value 4: D

Before circulation: ['A', 'B', 'C', 'D']


After circulation : ['D', 'A', 'B', 'C']

C) Distance Between Two Points

Algorithm:

1. Start the program


2. Import the math module
3. Read point coordinates (x1, y1) and (x2, y2) from the user
4. Apply the distance formula:
distance=(x2−x1)2+(y2−y1)2\text{distance} = \sqrt{(x2 - x1)^2 + (y2 -
y1)^2}distance=(x2−x1)2+(y2−y1)2
5. Display the calculated distance
6. Stop the program

Program:
import math

x1 = float(input("Enter x1: "))


y1 = float(input("Enter y1: "))
x2 = float(input("Enter x2: "))
y2 = float(input("Enter y2: "))

distance = [Link]((x2 - x1)**2 + (y2 - y1)**2)

print("\nDistance between points =", distance)

Sample Output

Enter x1: 2
Enter y1: 3
Enter x2: 8
Enter y2: 7
Distance between points = 7.211102550927978

Result:

Thus the above programs are successfully verified


EXPERIMENT 3
Scientific problems using Conditionals and Iterative loops (Number series, Number
Patterns, Pyramid pattern).

Aim: To implement conditionals and loops for solving mathematical and pattern
problems.

a) Number Series(Fibonacci Series (Using Loop))

Algorithm:

1. Start the program


2. Read the total number of terms (n)
3. Initialize first two numbers:
→ a = 0, b = 1
4. Display a and b
5. Repeat from 3rd term to n:
o Find next term c = a + b
o Display term c
o Update a = b and b = c
6. Stop the program

Program:

n = int(input("Enter number of terms: "))

a, b = 0, 1
print("Fibonacci Series:", a, b, end=" ")

for _ in range(2, n):


c=a+b
print(c, end=" ")
a, b = b, c

Sample Output

Enter number of terms: 6


Fibonacci Series: 0 1 1 2 3 5

b) Number Triangle Pattern

Algorithm:

1. Start the program


2. Read number of rows (n)
3. For each row i from 1 to n:
o Print numbers from 1 to i
4. Move to next line after each row
5. Stop the program
Program:

n = int(input("Enter rows: "))

for i in range(1, n+1):


for j in range(1, i+1):
print(j, end=" ")
print()

Sample Output

1
12
123
1234

C) Pyramid pattern

Algorithm:

1. Start the program


2. Read number of rows (n)
3. For each row i from 1 to n:
o Print (n−i) spaces
o Print (2×i−1) stars *
4. Move to next line after each row
5. Stop the program

Program:
n = int(input("Enter number of rows: "))
for i in range(1, n+1):
print(" "*(n-i) + "*"*(2*i-1))

Sample Output:
Input: 5
Output:
*
***
*****
*******
*********

Result:

Thus the above programs are successfully verified


EXPERIMENT 4
Implementing real-time/technical applications using Lists and Tuples.

Aim: To implement list and tuple-based applications in Python.

Algorithm / Procedure:

• Start program
• Create and manipulate lists/tuples
• Display results

a) Student Marks Analysis using List

Algorithm:

1. Start the program


2. Create a list containing marks of students
3. Calculate total number of students using len()
4. Calculate average marks using sum() / len()
5. Find highest and lowest marks using max() and min()
6. Display the results
7. Stop the program

Program:

marks = [78, 85, 92, 67, 88]

print("Marks List:", marks)

print("Total Students:", len(marks))

print("Average Marks:", sum(marks)/len(marks))

print("Highest Marks:", max(marks))

print("Lowest Marks:", min(marks))

Sample Output:
Marks List: [78, 85, 92, 67, 88]

Total Students: 5

Average Marks: 82.0

Highest Marks: 92

Lowest Marks: 67
b) RGB Color Representation using Tuple

Algorithm:

1. Start the program


2. Create a tuple with RGB color values
3. Display the complete tuple
4. Access and print each RGB value using index positions
5. Stop the program

Program:

color = (255, 0, 0) # Red color in RGB

print("Color in RGB:", color)

print("Red Value:", color[0])

print("Green Value:", color[1])

print("Blue Value:", color[2])

Sample Output:

Color in RGB: (255, 0, 0)

Red Value: 255

Green Value: 0

Blue Value: 0

Result:

Thus the above programs are successfully verified


EXPERIMENT 5
Implementing real-time/technical applications using Sets and Dictionaries
(Language, automobile components, etc.).

Aim: To use set and dictionary operations in Python applications.

Algorithm / Procedure:

• Start the program


• Create sets/dictionaries
• Perform operations and display results

a) Removing Duplicate Car Parts using Set

Algorithm:

1. Start the program


2. Create a set containing automobile component names
3. Display the set to show only unique items
4. Count the number of unique components using len()
5. Display the result
6. Stop the program

Program:

car_parts = {"Engine", "Wheels", "Brakes", "Doors", "Engine", "Seats"}

print("Car Components:", car_parts)

print("Total Unique Components:", len(car_parts))

Sample Output:

Car Components: {'Wheels', 'Seats', 'Engine', 'Brakes', 'Doors'}

Total Unique Components: 5

b) Language Translation Dictionary


Algorithm:

1. Start the program


2. Create a dictionary containing English words as keys and their Tamil translations
as values
3. Retrieve and display the Tamil translation for a specific English word
4. Display all available English words using dictionary keys
5. Stop the program
Program:

dictionary = {

"Hello": "Vanakkam",

"Thank You": "Nandri",

"Welcome": "Vaanga",

"Goodbye": "Poitu Varen"

print("Tamil Translation for 'Hello':", dictionary["Hello"])

print("Available Words:", [Link]())

Sample Output:

Tamil Translation for 'Hello': Vanakkam

Available Words: dict_keys(['Hello', 'Thank You', 'Welcome', 'Goodbye'])

Result:

Thus the above programs are successfully verified


EXPERIMENT 6
Implementing programs using Functions

(Factorial, largest number in list, area of shape).

Aim: To define and use functions for performing operations like factorial or finding
largest number.

a) Factorial of a Number
Algorithm:

1. Start the program


2. Define a function factorial(n)
o Initialize fact = 1
o Multiply numbers from 1 to n using a loop
o Return the factorial result
3. Accept or assign a number
4. Call the function with the given number
5. Display the factorial result
6. Stop the program

Program:

def factorial(n):

fact = 1

for i in range(1, n + 1):

fact *= i

return fact

num = 5

print("Factorial of", num, "is:", factorial(num))

Sample Output:
Factorial of 5 is: 120

b) Largest Number in a List


Algorithm:

1. Start the program


2. Define a function that returns the maximum element from a list using max()
3. Create a list with numeric values
4. Call the function by passing the list as an argument
5. Display the largest value returned by the function
6. Stop the program
Program:

def largest_number(numbers):

return max(numbers)

nums = [10, 56, 32, 89, 45]

print("List:", nums)

print("Largest Number:", largest_number(nums))

Sample Output:

List: [10, 56, 32, 89, 45]

Largest Number: 89

(C) Area of a Shape (Menu Based Function)

Algorithm:

1. Start the program


2. Define functions for:
o Area of a circle → πr²
o Area of a rectangle → l × b
o Area of a triangle → ½ × base × height
3. Display menu options for shape selection
4. Accept the user choice
5. Based on choice:
o Call respective function and display result
o If invalid choice → show error message
6. Stop the program

Program:

def area_circle(r):

return 3.14 * r * r

def area_rectangle(l, b):

return l * b

def area_triangle(b, h):

return 0.5 * b * h
print("1. Circle")

print("2. Rectangle")

print("3. Triangle")

choice = 1 # Example choice for demonstration

if choice == 1:

print("Area of Circle:", area_circle(7))

elif choice == 2:

print("Area of Rectangle:", area_rectangle(5, 10))

elif choice == 3:

print("Area of Triangle:", area_triangle(6, 8))

else:

print("Invalid Choice")

Sample Output:

Area of Circle: 153.86

Result:

Thus the above programs are successfully verified


EXPERIMENT 7
Implementing programs using Strings. (reverse, palindrome, character count,
replacing characters)

Aim: To manipulate and process strings using Python built-in functions.

a) Reverse a String
Algorithm:

1. Start the program


2. Assign a string to a variable
3. Reverse the string using slicing ([::-1])
4. Display the original and reversed string
5. Stop the program

Program:

text = "Python"

reversed_text = text[::-1]
print("Original String:", text)
print("Reversed String:", reversed_text)

Sample Output:
Original String: Python

Reversed String: nohtyP

b) Palindrome Check
Algorithm:

1. Start the program


2. Read or assign a word to a variable
3. Reverse the word using slicing
4. Compare the original word with the reversed one
5. If both are equal, print "Palindrome", else print "Not a Palindrome"
6. Stop the program

Program:
word = "madam"

if word == word[::-1]:
print(word, "is a Palindrome")
else:
print(word, "is Not a Palindrome")
Sample Output:
madam is a Palindrome

c) Character Count in a String


Algorithm:

1. Start the program


2. Assign a string to a variable
3. Create an empty dictionary to store character counts
4. Traverse each character in the string
5. If character already exists in dictionary, increment count
6. Else add the character with count = 1
7. Display the dictionary with character frequencies
8. Stop the program

Program:
text = "hello world"
char_count = {}

for char in text:


if char in char_count:
char_count[char] += 1
else:
char_count[char] = 1

print("Character Count:", char_count)

Sample Output:
Character Count: {'h': 1, 'e': 1, 'l': 3, 'o': 2, ' ': 1, 'w': 1, 'r': 1, 'd': 1}

d) Replace Characters in a String

Algorithm:

1. Start the program


2. Read or assign a string
3. Use the built-in replace() function to modify characters
4. Display the string before and after replacement
5. Stop the program

Program:

text = "programming"
new_text = [Link]("m", "M") # Replace 'm' with 'M'

print("Before Replace:", text)


print("After Replace:", new_text)
Sample Output:
Before Replace: programming

After Replace: prograMMing

Result:

Thus the above programs are successfully verified


EXPERIMENT 8
Implementing real-time/technical applications using File handling (copy one file to
another, word count, longest word).

Aim: To perform file operations such as read, write, copy, and word count.

Algorithm:

Step 1: Start

Step 2: Create/Open [Link] file

 Open the file in write mode ("w").


 Write some sample text into it.
 Close the file.

Step 3: Read content from [Link]

 Open [Link] in read mode ("r").


 Read the entire content and store it in a variable content.
 Close the file.

Step 4: Copy content to [Link]

 Open [Link] in write mode ("w").


 Write the content from step 3 into [Link].
 Close the file.
 Display: "File content copied successfully!"

Step 5: Count words in the file

 Split content into a list of words using split() → words.


 Count the number of words using len(words).
 Display: "Total Number of Words: <count>"

Step 6: Find the longest word

 Use max(words, key=len) to find the word with the maximum length →
longest_word.
 Display: "Longest Word in File: <longest_word>"

Step 7: End

Program:

# Creating a sample input file

with open("[Link]", "w") as f:

[Link]("Python programming makes technology easier and smarter")


# Copy content from [Link] → [Link]

with open("[Link]", "r") as f1:

content = [Link]()

with open("[Link]", "w") as f2:

[Link](content)

print("File content copied successfully!")

# Word Count

words = [Link]()

print("Total Number of Words:", len(words))

# 3 Longest Word in the file

longest_word = max(words, key=len)

print("Longest Word in File:", longest_word)

Sample Output:
File content copied successfully!

Total Number of Words: 7

Longest Word in File: programming

Result:

Thus the above programs are successfully verified


EXPERIMENT 9
Implementing real-time/technical applications using Exception handling (divide by
zero error, voter’s age, validation).

Aim: To handle runtime errors using try-except blocks in Python.

Algorithm:

Step 1: Start the program

Step 2: Divide by Zero Handling

 Use a try block to perform division.


 If division by zero occurs, handle it using except ZeroDivisionError.
 Display appropriate error message.

Step 3: Voter Age Validation

 Use a try block to take age input from the user.


 If the age is negative, raise ValueError.
 If age < 18, display "Not Eligible for Voting"; otherwise, display "Eligible for
Voting".
 Handle invalid inputs using except ValueError.

Step 4: Name Validation

 Use a try block to take name input from the user.


 If the name contains non-alphabet characters, raise Exception.
 Otherwise, accept the name.
 Handle invalid names using except Exception.

Step 5: End

Program:

try:
# Divide by Zero Handling
num1 = 10
num2 = 0
result = num1 / num2
print("Division Result:", result)

except ZeroDivisionError:
print("Error: Cannot divide a number by Zero!")
try:
# Voter Age Validation

age = int(input("Enter Age: "))

if age < 0:
raise ValueError("Age cannot be Negative!")
elif age < 18:
print("Not Eligible for Voting")
else:
print("Eligible for Voting")

except ValueError as e:
print("Invalid Input:", e)

try:
# General Validation - Only alphabets allowed
name = input("Enter your Name: ")

if not [Link]():
raise Exception("Name must contain only alphabets!")
else:
print("Name Accepted:", name)

except Exception as e:
print("Validation Error:", e)

Sample Output:
Error: Cannot divide a number by Zero!
Enter Age: 17
Not Eligible for Voting
Enter your Name: John123
Validation Error: Name must contain only alphabets!

Result:

Thus the above programs are successfully verified


EXPERIMENT 10
Bouncing Ball Game using Pygame

Aim: To explore Pygame and develop basic 2D games.

Algorithm:

1. Start the program


2. Initialize Pygame using [Link]().
3. Set screen dimensions and create the display window.
4. Define colors for the screen background and the ball.
5. Initialize ball properties:
o Position (x, y)
o Radius
o Speed (speed_x, speed_y)
6. Create the game loop:
o Check for events (like quitting the game).
o Update ball position using speed values.
o Check for collision with screen edges:
 Reverse speed_x if hitting left or right edges.
 Reverse speed_y if hitting top or bottom edges.
o Clear the screen and draw the ball at the new position.
o Update the display using [Link]().
o Control frame rate using [Link](60) for smooth animation.
7. End

Program:

import pygame
import sys

# Initialize Pygame
[Link]()

# Screen settings
width, height = 600, 400
screen = [Link].set_mode((width, height))
[Link].set_caption("Bouncing Ball Game")

# Colors
white = (255, 255, 255)
red = (255, 0, 0)

# Ball properties
x = 100
y = 100
radius = 20
speed_x = 3
speed_y = 3
clock = [Link]()
# Game Loop
while True:
for event in [Link]():
if [Link] == [Link]:
[Link]()
[Link]()

# Move the ball


x += speed_x
y += speed_y

# Collision detection with screen edges


if x - radius <= 0 or x + radius >= width:
speed_x = -speed_x

if y - radius <= 0 or y + radius >= height:


speed_y = -speed_y

# Fill screen and draw ball


[Link](white)
[Link](screen, red, (x, y), radius)

[Link]()
[Link](60)

Sample Output:
- Ball moves left-right & up-down

- Bounces when hitting edges

- Smooth animation at 60 FPS

Result:

Thus the above programs are successfully verified


Additional Experiments

11. Implement a Python Program to Perform Matrix Addition and Matrix


Multiplication

Aim:

To write a Python program that performs matrix addition and multiplication using nested
lists.

Algorithm:

1. Start the program.


2. Define two matrices using nested lists.
3. Use nested loops to add corresponding elements of the matrices.
4. Use nested loops to perform matrix multiplication:
o Multiply rows of the first matrix by columns of the second matrix.
o Sum the products to get each element of the resulting matrix.
5. Display the resulting matrices.
6. End the program.

Program:
A = [[1, 2, 3],[4, 5, 6]]

B = [[7, 8, 9], [1, 2, 3]]

# Matrix Addition
add = []
foriinrange(len(A)):
row = []
for j inrange(len(A[0])):
[Link](A[i][j] + B[i][j])
[Link](row)

print("Matrix Addition:")
for r in add:
print(r)

# Matrix Multiplication
A2 = [[1, 2],
[3, 4],
[5, 6]]

B2 = [[7, 8, 9],
[1, 2, 3]]

result = []
foriinrange(len(A2)):
row = []
for j inrange(len(B2[0])):
s=0
for kinrange(len(B2)):
s += A2[i][k] * B2[k][j]
[Link](s)
[Link](row)

print("\nMatrix Multiplication:")
for r in result:
print(r)
Sample Output:
Matrix Addition:
[8, 10, 12]
[5, 7, 9]

Matrix Multiplication:
[9, 12, 15]
[25, 34, 43]
[41, 56, 71]

Result:

Thus the above programs are successfully verified


12. Implement a Python Program to Simulate a Simple Banking System (Deposit,
Withdraw, Check Balance)

Aim:

To create a simple menu-driven banking application using loops and functions.

Algorithm:

1. Start the program.


2. Initialize balance = 0.
3. Display a menu with options: Deposit, Withdraw, Check Balance, Exit.
4. Take user input for the choice.
5. Perform the corresponding operation:
o Deposit: Add the amount to balance.
o Withdraw: Subtract the amount from balance if sufficient funds exist;
otherwise, show an error.
o Check Balance: Display current balance.
6. Repeat the menu until the user chooses Exit.
7. End the program.

Program:
balance = 0

defdeposit(amount):
global balance
balance += amount
print("Amount Deposited:", amount)

defwithdraw(amount):
global balance
if amount > balance:
print("Insufficient Balance!")
else:
balance -= amount
print("Amount Withdrawn:", amount)

defcheck_balance():
print("Current Balance:", balance)

whileTrue:
print("\n--- Banking System ---")
print("1. Deposit")
print("2. Withdraw")
print("3. Check Balance")
print("4. Exit")
choice = int(input("Enter choice: "))

if choice == 1:

amt = int(input("Enter amount: "))


deposit(amt)
elif choice == 2:
amt = int(input("Enter amount: "))
withdraw(amt)
elif choice == 3:
check_balance()
elif choice == 4:
print("Thank you!")
break
else:
print("Invalid choice!")

Sample Output:
---BankingSystem---
[Link]
[Link]
[Link]
[Link]
Enter choice:1
Enter amount:500
Amount Deposited:500

Enter choice:2
Enter amount:200
Amount Withdrawn:200

Enter choice:3
Current Balance:300

Result:

Thus the above programs are successfully verified

You might also like