- import os
- from datetime import datetime
- enableCLS = False
- def screen_clear():
- if enableCLS:
- print("Screen_clear is ON ! ")
- if os.name == 'posix':
- _ = os.system('clear')
- else:
- _ = os.system('cls')
- else:
- print("screen clear is off !")
- def ClearScreenSetting():
- global enableCLS
- ch = input("\nDo you want to enable \"Clear screen\"?\n\Press Y for yes , any other keys for NO : ")
- if ch == 'Y' or ch == 'y':
- enableCLS = True
- else:
- enableCLS = False
- #create bus
- def createBus():
- file = open("bus.txt", "a")
- bus_ID = input("Enter bus ID in format: bus number_destination Town. Example: 2344_Kajang: ")
- date = str(input("Enter departure date(yyyy-mm-dd):"))
- time = str(input("Enter departure time(hh:mm)): " ))
- dtown = str(input("Departure town: "))
- atown = str(input("Arrival town: "))
- seat = int(input("Total seat available: "))
- fare = float(input("Fare per seat: "))
- file.write("\n" +str(bus_ID)+ "," +str(date)+ "," +str(time)+ "," +dtown+ "," +atown+ "," +str(seat)+ "," +str(fare)+"\n")
- file.close()
- print("Bus created successfully")
- #edit bus
- def editBus():
- file = open("bus.txt")
- print(file.read())
- bus_ID = input("Enter bus ID in format: bus number_destination Town. Example: 2344_Klang: ")
- if (bus_ID in file.read()):
- if seat >= 42:
- file = open("bus.txt", "w")
- file.close()
- else:
- print("You cannot edit the bus information because it is booked")
- else:
- print("You cannot edit the bus information because it does not exist")
- bus()
- #homepage
- def bus():
- screen_clear()
- print(" _____________________________________________")
- print(" | Welcome to Bus Information System ! |")
- print(" | Enter [x] to enable screen clear mode |")
- print(" | Enter [1] to view existing bus |")
- print(" | Enter [2] to register new bus |")
- print(" | Enter [3] to edit empty exixting bus |")
- print(" | Enter [4] to delete bus |")
- print(" | Enter [5] to exit from the programme |")
- print(" ----------------------------------------------")
- choice = input("PLease Enter according to your needs :")
- return choice
- def main(): # function before login
- global bus_ID
- print("This plastform is", os.name)
- exitProgram = False
- while exitProgram == False:
- choice = bus()
- if choice == 'x' or choice == 'X':
- ClearScreenSetting()
- elif choice == '1':
- bus_ID = input("Enter bus ID: ")
- if bus_ID == False:
- print("Please enter a valid bus ID")
- else:
- viewBus(bus_ID)
- elif choice == '2':
- createBus()
- input("Bus information created successfully !! [Enter any key to continue] ")
- bus()
- elif choice == '3':
- editBus()
- input("Bus information edited succesfully !! [Enter any key to continue] ")
- bus()
- elif choice == '4':
- delBus()
- input("Bus information deleted !! [Enter any key to continue] ")
- bus()
- elif choice == '5':
- print("Thank you for using our website !")
- exitProgram = True
- main()
[text] Module2New
Viewer
*** This page was generated with the meta tag "noindex, nofollow". This happened because you selected this option before saving or the system detected it as spam. This means that this page will never get into the search engines and the search bot will not crawl it. There is nothing to worry about, you can still share it with anyone.
Editor
You can edit this paste and save as new: