Python Bike Rental System (Project)

Python Bike Rental System:

We can use the PyCharm code editor for this example. If you do not know about it then follow this link- How to install PyCharm for Python and create a program in it.

Code Unit:

Python Bike Rental System Code Unit
python bike rental system

Output:

Python Bike Rental System Output

Python Bike Rental System Source Code: Do proper Code Indentation otherwise, the Source Code does not work and gives an error.

class bike_rent_shop:
   def __init__(self,bike_stock):
       self.stock=bike_stock

   def display_bike(self):
           print("Total Bikes Availabale", self.stock)

   def rent_Bike(self, x):

       if x <= 0:
        print("Enter the Positive Value or Greater than Zero")
       elif x > self.stock:
        print("Sorry!! Required Quantity of Stock is not Availabale")
       else:
           self.stock = self.stock - x
           print("Total Prices", x * 150)
           print("Total Bikes Availabale", self.stock)

while True:
   obj=bike_rent_shop(200)
   user_choice=int(input('''
   1 Display Stocks
   2 Rent a Bike
   3 Exit
   '''))

   if user_choice == 1:
       obj.display_bike()
   elif user_choice == 2:
       y = int(input("Enter the Required Quantity:----"))
       obj.rent_Bike(y)
   else:
      break

Computer Software and Hardware
Malicious Software (Malware)
Database Management System (DBMS)
Object-Oriented Programming (OOP)
Tutorial MySQL
Tutorial Python
Python (programming language)– Wikipedia

Comments (No)

Leave a Reply