Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create M. Shanmugaraj #29

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

Rajabi123
Copy link

@Rajabi123 Rajabi123 commented Oct 27, 2023

BankAccount:
def init(self, account_number, account_holder_name, initial_balance):
self.__account_number = account_number
self.__account_holder_name = account_holder_name
self.__account_balance = initial_balance

def deposit(self, amount):
    if amount > 0:
        self.__account_balance += amount
        print(f"Deposited ₹{amount}. New balance: ₹{self.__account_balance}")
    else:
        print("Invalid deposit amount. Amount must be greater than 0.")

def withdraw(self, amount):
    if 0 < amount <= self.__account_balance:
        self.__account_balance -= amount
        print(f"Withdrew ₹{amount}. New balance: ₹{self.__account_balance}")
    else:
        print("Invalid withdrawal amount or insufficient funds.")

def display_balance(self):
    print(f"Account Balance for {self.__account_holder_name} (Account #{self.__account_number}): ₹{self.__account_balance}")

my_account = BankAccount("12345", "SRIDHARAN MSD", 1000) print("Welcome to My Bank")

while True:
print("1. Check balance\n2. Deposit\n3. Withdraw\n4. Exit")
choice = int(input("Enter Your Choice: "))

if choice == 1:
    my_account.display_balance()
elif choice == 2:
    n = int(input("Enter the amount to deposit: "))
    my_account.deposit(n)
    print("Amount Deposited Successfully")
elif choice == 3:
    m = int(input("Enter the amount to withdraw: "))
    my_account.withdraw(m)
elif choice == 4:
    print("Thank you for using My Bank. Goodbye!")
    break
else:
    print("Invalid choice. Please select a valid option.")

[26/10, 7:47 pm] Hariram: year = int(input("Enter a year: "))

if year % 400 == 0:
print(f"{year} is a leap year")
elif year % 100 == 0:
print(f"{year} is not a leap year")
elif year % 4 == 0:
print(f"{year} is a leap year")
else:
print(f"{year} is not a leap year")
[26/10, 7:47 pm] Hariram: def factorial(n):
if n == 0:
return 1
else:
return n * factorial(n - 1)

n=int(input("Enter the integer number"))
result = factorial(n)
print(f"The factorial of {n} is {result}")
[26/10, 7:47 pm] Hariram: def linear_search_product(product_list, target_product):
indices = []

for i in range(len(product_list)):
    if product_list[i] == target_product:
        indices.append(i)

return indices

n = int(input("ENTER THE NUMBER OF ITEMS IN PRODUCT LIST:")) strings = []
print(f"ENTER THE {n} ITEMS")
for j in range(n):
product = input()
strings.append(product)

target = input("ENTER THE TARGET PRODUCT TO SEARCH: ") result = linear_search_product(strings, target)

if result:
print(f"Indices of target product '{target}': {result}")
else:
print(f"Target product '{target}' not found in the list.")
[26/10, 7:47 pm] Hariram: class Player:
def play(self):
print ("The player is playing cricket ")

class Batsman(Player):
def play(self):
print("The batsman is batting ")

class Bowler(Player):
def play(self):
print("The bowler is bowling ")

batsman=Batsman()
bowler=Bowler()

batsman.play()
bowler.play()
[26/10, 7:47 pm] Hariram: class Student:
def init(self, name, roll_no, cgpa):
self.name = name
self.roll_no = roll_no
self.cgpa = cgpa

def get_student_data():
student_list = []
while True:
name = input("Enter student name (or type 'done' to finish): ")
if name.lower() == 'done':
break
roll_no = input("Enter student roll number: ")
cgpa = float(input("Enter student CGPA: "))
student = Student(name, roll_no, cgpa)
student_list.append(student)
return student_list

def sort_students(student_list):
n = len(student_list)
for i in range(n - 1):
for j in range(0, n - i - 1):
if student_list[j].cgpa < student_list[j + 1].cgpa:
student_list[j], student_list[j + 1] = student_list[j + 1], student_list[j]

return student_list

if name == "main":
students = get_student_data()
sorted_students = sort_students(students)
print("\nSorted List of Students:")
for student in sorted_students:
print(f"Name: {student.name}, RollNumber: {student.roll_no}, CGPA: {student.cgpa}")

[26/10, 7:47 pm] Hariram: class BankAccount:
    def __init__(self, account_number, account_holder_name, initial_balance):
        self.__account_number = account_number
        self.__account_holder_name = account_holder_name
        self.__account_balance = initial_balance

    def deposit(self, amount):
        if amount > 0:
            self.__account_balance += amount
            print(f"Deposited ₹{amount}. New balance: ₹{self.__account_balance}")
        else:
            print("Invalid deposit amount. Amount must be greater than 0.")

    def withdraw(self, amount):
        if 0 < amount <= self.__account_balance:
            self.__account_balance -= amount
            print(f"Withdrew ₹{amount}. New balance: ₹{self.__account_balance}")
        else:
            print("Invalid withdrawal amount or insufficient funds.")

    def display_balance(self):
        print(f"Account Balance for {self.__account_holder_name} (Account #{self.__account_number}): ₹{self.__account_balance}")


my_account = BankAccount("12345", "SRIDHARAN MSD", 1000)
print("Welcome to My Bank")

while True:
    print("1. Check balance\n2. Deposit\n3. Withdraw\n4. Exit")
    choice = int(input("Enter Your Choice: "))

    if choice == 1:
        my_account.display_balance()
    elif choice == 2:
        n = int(input("Enter the amount to deposit: "))
        my_account.deposit(n)
        print("Amount Deposited Successfully")
    elif choice == 3:
        m = int(input("Enter the amount to withdraw: "))
        my_account.withdraw(m)
    elif choice == 4:
        print("Thank you for using My Bank. Goodbye!")
        break
    else:
        print("Invalid choice. Please select a valid option.")
[26/10, 7:47 pm] Hariram: year = int(input("Enter a year: "))

if year % 400 == 0:
    print(f"{year} is a leap year")
elif year % 100 == 0:
    print(f"{year} is not a leap year")
elif year % 4 == 0:
    print(f"{year} is a leap year")
else:
    print(f"{year} is not a leap year")
[26/10, 7:47 pm] Hariram: def factorial(n):
    if n == 0:
        return 1
    else:
        return n * factorial(n - 1)

n=int(input("Enter the integer number"))
result = factorial(n)
print(f"The factorial of {n} is {result}")
[26/10, 7:47 pm] Hariram: def linear_search_product(product_list, target_product):
    indices = []
    
    for i in range(len(product_list)):
        if product_list[i] == target_product:
            indices.append(i)
    
    return indices

n = int(input("ENTER THE NUMBER OF ITEMS IN PRODUCT LIST:"))
strings = []
print(f"ENTER THE {n} ITEMS")
for j in range(n):
    product = input()
    strings.append(product)

target = input("ENTER THE TARGET PRODUCT TO SEARCH: ")
result = linear_search_product(strings, target)

if result:
    print(f"Indices of target product '{target}': {result}")
else:
    print(f"Target product '{target}' not found in the list.")
[26/10, 7:47 pm] Hariram: class Player:
  def play(self):
    print ("The player is playing cricket ")

class Batsman(Player):
  def play(self):
    print("The batsman is batting ")

class Bowler(Player):
  def play(self):
    print("The bowler is bowling ")

batsman=Batsman()
bowler=Bowler()

batsman.play()
bowler.play()
[26/10, 7:47 pm] Hariram: class Student:
    def __init__(self, name, roll_no, cgpa): 
        self.name = name
        self.roll_no = roll_no  
        self.cgpa = cgpa

def get_student_data():
    student_list = []
    while True:
        name = input("Enter student name (or type 'done' to finish): ")
        if name.lower() == 'done':
            break
        roll_no = input("Enter student roll number: ") 
        cgpa = float(input("Enter student CGPA: "))
        student = Student(name, roll_no, cgpa)
        student_list.append(student)
    return student_list

def sort_students(student_list):
    n = len(student_list)
    for i in range(n - 1):
        for j in range(0, n - i - 1):
            if student_list[j].cgpa < student_list[j + 1].cgpa:
                student_list[j], student_list[j + 1] = student_list[j + 1], student_list[j]

    return student_list

if __name__ == "__main__":  
    students = get_student_data()
    sorted_students = sort_students(students)
    print("\nSorted List of Students:")
    for student in sorted_students:
        print(f"Name: {student.name}, RollNumber: {student.roll_no}, CGPA: {student.cgpa}")
@Dearmary
Copy link

Dearmary commented Oct 27, 2023 via email

@Rajabi123
Copy link
Author

Fundamental

@Rajabi123
Copy link
Author

class BankAccount:
def init(self, account_number, account_holder_name, initial_balance):
self.__account_number = account_number
self.__account_holder_name = account_holder_name
self.__account_balance = initial_balance

def deposit(self, amount):
    if amount > 0:
        self.__account_balance += amount
        print(f"Deposited ₹{amount}. New balance: ₹{self.__account_balance}")
    else:
        print("Invalid deposit amount. Amount must be greater than 0.")

def withdraw(self, amount):
    if 0 < amount <= self.__account_balance:
        self.__account_balance -= amount
        print(f"Withdrew ₹{amount}. New balance: ₹{self.__account_balance}")
    else:
        print("Invalid withdrawal amount or insufficient funds.")

def display_balance(self):
    print(f"Account Balance for {self.__account_holder_name} (Account #{self.__account_number}): ₹{self.__account_balance}")

my_account = BankAccount("12345", "SRIDHARAN MSD", 1000)
print("Welcome to My Bank")

while True:
print("1. Check balance\n2. Deposit\n3. Withdraw\n4. Exit")
choice = int(input("Enter Your Choice: "))

if choice == 1:
    my_account.display_balance()
elif choice == 2:
    n = int(input("Enter the amount to deposit: "))
    my_account.deposit(n)
    print("Amount Deposited Successfully")
elif choice == 3:
    m = int(input("Enter the amount to withdraw: "))
    my_account.withdraw(m)
elif choice == 4:
    print("Thank you for using My Bank. Goodbye!")
    break
else:
    print("Invalid choice. Please select a valid option.")

[26/10, 7:47 pm] Hariram: year = int(input("Enter a year: "))

if year % 400 == 0:
print(f"{year} is a leap year")
elif year % 100 == 0:
print(f"{year} is not a leap year")
elif year % 4 == 0:
print(f"{year} is a leap year")
else:
print(f"{year} is not a leap year")
[26/10, 7:47 pm] Hariram: def factorial(n):
if n == 0:
return 1
else:
return n * factorial(n - 1)

n=int(input("Enter the integer number"))
result = factorial(n)
print(f"The factorial of {n} is {result}")
[26/10, 7:47 pm] Hariram: def linear_search_product(product_list, target_product):
indices = []

for i in range(len(product_list)):
    if product_list[i] == target_product:
        indices.append(i)

return indices

n = int(input("ENTER THE NUMBER OF ITEMS IN PRODUCT LIST:"))
strings = []
print(f"ENTER THE {n} ITEMS")
for j in range(n):
product = input()
strings.append(product)

target = input("ENTER THE TARGET PRODUCT TO SEARCH: ")
result = linear_search_product(strings, target)

if result:
print(f"Indices of target product '{target}': {result}")
else:
print(f"Target product '{target}' not found in the list.")
[26/10, 7:47 pm] Hariram: class Player:
def play(self):
print ("The player is playing cricket ")

class Batsman(Player):
def play(self):
print("The batsman is batting ")

class Bowler(Player):
def play(self):
print("The bowler is bowling ")

batsman=Batsman()
bowler=Bowler()

batsman.play()
bowler.play()
[26/10, 7:47 pm] Hariram: class Student:
def init(self, name, roll_no, cgpa):
self.name = name
self.roll_no = roll_no
self.cgpa = cgpa

def get_student_data():
student_list = []
while True:
name = input("Enter student name (or type 'done' to finish): ")
if name.lower() == 'done':
break
roll_no = input("Enter student roll number: ")
cgpa = float(input("Enter student CGPA: "))
student = Student(name, roll_no, cgpa)
student_list.append(student)
return student_list

def sort_students(student_list):
n = len(student_list)
for i in range(n - 1):
for j in range(0, n - i - 1):
if student_list[j].cgpa < student_list[j + 1].cgpa:
student_list[j], student_list[j + 1] = student_list[j + 1], student_list[j]

return student_list

if name == "main":
students = get_student_data()
sorted_students = sort_students(students)
print("\nSorted List of Students:")
for student in sorted_students:
print(f"Name: {student.name}, RollNumber: {student.roll_no}, CGPA: {student.cgpa}")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants