From 08d7761d0e2cce9d89a98687699922e139fe3a81 Mon Sep 17 00:00:00 2001 From: Akash Kumar Singh <57872097+akashkumarsingh612@users.noreply.github.com> Date: Thu, 1 Oct 2020 13:39:18 +0530 Subject: [PATCH 01/12] Update beta.py --- beta.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/beta.py b/beta.py index 2468cc8..5198343 100644 --- a/beta.py +++ b/beta.py @@ -1,3 +1,10 @@ +# Python HelloWorld Program def run(): - print('Hello, Python.') - print("Hi, Github") + print("Hello, Python Programmers.") + print("Hey, Github") +# OR + +def hello(): + return 'Hello, Python' + return 'Hey, Github' + From 993120ee290d61e775f415ea75fba14e458a574b Mon Sep 17 00:00:00 2001 From: Akash Kumar Singh <57872097+akashkumarsingh612@users.noreply.github.com> Date: Mon, 28 Dec 2020 11:09:31 +0530 Subject: [PATCH 02/12] Airways Management system --- Airways Management System | 237 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 237 insertions(+) create mode 100644 Airways Management System diff --git a/Airways Management System b/Airways Management System new file mode 100644 index 0000000..bf694af --- /dev/null +++ b/Airways Management System @@ -0,0 +1,237 @@ +# Airways Management System + +import pickle # we are using pickle bec it operates binary files (will increase performance of program). +import os # we are using os to handle some operation with file like renaming and deleting. +import pyttsx3 # this is Python text-to-speech which gives a voice to our Airways Management System. + +flight_det = {} + +def speak(line): + '''it will give a female voice to Every line given as argument(parameter)''' + voice_id = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Speech\Voices\Tokens\TTS_MS_EN-US_ZIRA_11.0" + voice = pyttsx3.init() + voice.setProperty('voice', voice_id) + voice.say(line) + voice.runAndWait() + +def say(line): + '''it is Same as speak() but dude it speaks in Male voice''' + voice_id = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Speech\Voices\Tokens\TTS_MS_EN-US_DAVID_11.0" + voice = pyttsx3.init() + voice.setProperty('voice', voice_id) + voice.say(line) + voice.runAndWait() + + +def write_data(): + ''' It will add flight details(data) in flight.dat ''' + with open("flight.dat", "ab") as fdata: + say('Helloo, Please Write the Number of Flights you want write in file') + No_Of_flight = int(input("Enter the Number of Flights : ")) + for num in range(No_Of_flight): + speak(f'Please Write, {num+1} flight Number') + flight_det["flightNo"] = int(input(f"\nPlease Enter {num + 1} Flight Number : ")) + speak(f'Please Write Name of Flight-{flight_det["flightNo"]}') + flight_det["fname"] = input(f'Enter Name of Flight-{flight_det["flightNo"]} : ') + speak(f'Please Write Fare of {flight_det["fname"]}-{flight_det["flightNo"]}') + flight_det["fare"] = int(input(f'Enter Fare of {flight_det["fname"]}-{flight_det["flightNo"]} : ')) + pickle.dump(flight_det, fdata) + + +def show_data(): + ''' it will Display all the Flights Data inside flight.dat file''' + try: + with open("flight.dat", "rb") as fdata: + while True: + print(f'{ pickle.load(fdata)}') + except Exception: + pass + + +def del_data(): + speak('Please Enter Flight Number to delete its DATA') + flightNo = int(input("\nPlease Enter Flight Number to delete its DATA : ")) + try: + with open("flight.dat", "rb") as fdata1: + with open("temp.dat", "ab") as fdata2: + data = pickle.load(fdata1) + if data["flightNo"] == flightNo: + pass + else: + pickle.dump(data, fdata2) + except Exception: + say("Error : There is no Data in flight.dat") + print("Error : There is no Data in flight.dat") + os.remove("flight.dat") + os.rename("temp.dat", "flight.dat") + + try: + with open("flight.dat", "rb") as fdata: + while True: + speak("Here's the Record of Flights after Deletion") + print(f'\n Record of Flights after Deletion :\n {pickle.load(fdata)}') + except Exception: + pass + +def search(): + try: + with open('flight.dat', 'rb') as fdata: + speak(" Please Enter Flight Number to Search its Details") + fsearch = int(input("\nEnter Flight Number to Search : ")) + datafound = 0 + while True: + data = pickle.load(fdata) + if data['flightNo'] == fsearch: + datafound = 1 + speak("Here's the Search Details") + print(f'Search Result : \n {data}') + say(data) + break + if datafound == 0: + speak(f'Details of flight-{fsearch} was NOT FOUND') + print(f"\n ! Details of flight-{fsearch} was NOT FOUND !") + except Exception: + print("Error : There is no Data in flight.dat") + + +def update_data(): + with open("file.dat", "rb") as fdata: + with open("temp.dat", "wb") as fdata2: + speak("Enter Flight Number to Update") + flightNo = int(input("Enter Flight Number to Update : ")) + try: + while True: + data = pickle.load(fdata) + if data["flightNo"] == flightNo: + print("Enter Flight New Details : \n") + data["flightNo"] = int(input("Enter Flight Number : ")) + data["fname"] = input("Enter Flight's Name : ") + data["fare"] = int(input("Enter the Fare : ")) + pickle.dump(data, fdata2) + else: + pickle.dump(data, fdata2) + except EOFError: + pass + os.remove("flight.dat") + os.rename("temp.dat", "flight.dat") + + +def flower(): + import turtle + turtle.penup() + turtle.left(90) + turtle.fd(200) + turtle.pendown() + turtle.right(90) + turtle.fillcolor("red") + turtle.begin_fill() + turtle.circle(10, 180) + turtle.circle(25, 110) + turtle.left(50) + turtle.circle(60, 45) + turtle.circle(20, 170) + turtle.right(24) + turtle.fd(30) + turtle.left(10) + turtle.circle(30, 110) + turtle.fd(20) + turtle.left(40) + turtle.circle(90, 70) + turtle.circle(30, 150) + turtle.right(30) + turtle.fd(15) + turtle.circle(80, 90) + turtle.left(15) + turtle.fd(45) + turtle.right(165) + turtle.fd(20) + turtle.left(155) + turtle.circle(150, 80) + turtle.left(50) + turtle.circle(150, 90) + turtle.end_fill() + turtle.left(150) + turtle.circle(-90, 70) + turtle.left(20) + turtle.circle(75, 105) + turtle.setheading(60) + turtle.circle(80, 98) + turtle.circle(-90, 40) + turtle.left(180) + turtle.circle(90, 40) + turtle.circle(-80, 98) + turtle.setheading(-83) + turtle.fd(30) + turtle.left(90) + turtle.fd(25) + turtle.left(45) + turtle.fillcolor("green") + turtle.begin_fill() + turtle.circle(-80, 90) + turtle.right(90) + turtle.circle(-80, 90) + turtle.end_fill() + turtle.right(135) + turtle.fd(60) + turtle.left(180) + turtle.fd(85) + turtle.left(90) + turtle.fd(80) + turtle.right(90) + turtle.right(45) + turtle.fillcolor("green") + turtle.begin_fill() + turtle.circle(80, 90) + turtle.left(90) + turtle.circle(80, 90) + turtle.end_fill() + turtle.left(135) + turtle.fd(60) + turtle.left(180) + turtle.fd(60) + turtle.right(90) + turtle.circle(200, 60) + turtle.done() + + +speak_one_time = 0 +speak_one = 0 +while True: + if speak_one == 0: + say("Enter Number to choose specific operation you want to perform") + speak_one = 1 + print('\nOperations :\n 1 - Add Flight Details.\n 2 - Show Flight Details\n 3 - Update Flight Details. ') + print(' 4 - Delete Flight Detail.\n 5 - Search Flights.\n 6 - Clock.\n 7 - EXIT.') + if speak_one_time == 0: + speak("1 for Adding Flight Details, 2 for Displaying flight details, 3 to Update flight details" + ",4 for Deleting flight details, 5 to Search Flights, 6 to know current timings, and 7 for Exit") + speak_one_time = 1 + op = int(input("\nEnter Number to Choose Operation : ")) + if op == 1: + write_data() + elif op == 2: + print(f"\nFlights Details : ") + show_data() + elif op == 3: + update_data() + elif op == 4: + del_data() + elif op == 5: + search() + elif op == 6: + import time + live_time = time.strftime("%H:%M:%S") + speak(f"The Current timings are : {live_time}") + print(f"\n| The Current timings are : {live_time} |") + elif op == 7: + say("Thanks for Using Airways Management System") + print("Thanks for Using Airways Management System") + say("Creators of this, Airways Management System are |Akash kumar Singh, |Rohit Kumar and Pawan Meena ") + print("Creators of Airways Management System :\n | Akash kumar Singh | Rohit kumar | Pawan Meena |") + speak("Here's a Flower for you DEAR") + flower() + speak("See You Again! Bye Dear") + break + else: + speak("Hey, Please Choose the Correct Operations!") + print("Please Choose CORRECT Operation!") From 1851db4ddf5e3293f56b7a3d53f9d7b838960917 Mon Sep 17 00:00:00 2001 From: Akash Kumar Singh <57872097+akashkumarsingh612@users.noreply.github.com> Date: Mon, 28 Dec 2020 11:33:46 +0530 Subject: [PATCH 03/12] Update Airways Management System --- Airways Management System | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Airways Management System b/Airways Management System index bf694af..77acba9 100644 --- a/Airways Management System +++ b/Airways Management System @@ -95,7 +95,7 @@ def search(): def update_data(): - with open("file.dat", "rb") as fdata: + with open("flight.dat", "rb") as fdata: with open("temp.dat", "wb") as fdata2: speak("Enter Flight Number to Update") flightNo = int(input("Enter Flight Number to Update : ")) From 532d1ec42feb8d7867766ffc459404bc0be01bf3 Mon Sep 17 00:00:00 2001 From: Akash Kumar Singh <57872097+akashkumarsingh612@users.noreply.github.com> Date: Mon, 28 Dec 2020 12:09:24 +0530 Subject: [PATCH 04/12] Update Airways Management System --- Airways Management System | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Airways Management System b/Airways Management System index 77acba9..6f048ca 100644 --- a/Airways Management System +++ b/Airways Management System @@ -67,9 +67,10 @@ def del_data(): try: with open("flight.dat", "rb") as fdata: + speak("Here's the Record of Flights after Deletion\n") + print('Record of Flights after Deletion :\n') while True: - speak("Here's the Record of Flights after Deletion") - print(f'\n Record of Flights after Deletion :\n {pickle.load(fdata)}') + print(f' {pickle.load(fdata)}') except Exception: pass @@ -108,12 +109,14 @@ def update_data(): data["fname"] = input("Enter Flight's Name : ") data["fare"] = int(input("Enter the Fare : ")) pickle.dump(data, fdata2) + break else: pickle.dump(data, fdata2) except EOFError: pass - os.remove("flight.dat") - os.rename("temp.dat", "flight.dat") + os.remove("flight.dat") + os.rename("temp.dat", "flight.dat") + def flower(): From 340105dbeac9104dde1048c310a7a856cbc3fdf8 Mon Sep 17 00:00:00 2001 From: Akash Kumar Singh <57872097+akashkumarsingh612@users.noreply.github.com> Date: Mon, 28 Dec 2020 13:21:14 +0530 Subject: [PATCH 05/12] Update Airways Management System --- Airways Management System | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Airways Management System b/Airways Management System index 6f048ca..6d9e441 100644 --- a/Airways Management System +++ b/Airways Management System @@ -1,3 +1,7 @@ +Make Sure You've Installed Python Text to speech i.e. pyttsx3 +If not then Open Command Prompt and type : pip install pyttsx3 +Source Code : + # Airways Management System import pickle # we are using pickle bec it operates binary files (will increase performance of program). From 11444a650842ea6e828b46171bc5307f96e09d7b Mon Sep 17 00:00:00 2001 From: Akash Kumar Singh <57872097+akashkumarsingh612@users.noreply.github.com> Date: Mon, 28 Dec 2020 18:40:34 +0530 Subject: [PATCH 06/12] Create Library Management System --- Library Management System | 119 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 119 insertions(+) create mode 100644 Library Management System diff --git a/Library Management System b/Library Management System new file mode 100644 index 0000000..6d2cdf1 --- /dev/null +++ b/Library Management System @@ -0,0 +1,119 @@ + +import pickle +import os + +lib_data = {} + + +def add_books(): + file = open("library.dat", 'ab') + num = int(input("Enter Number of Books you want to add : ")) + for i in range(num): + print(f"Enter Details of Books-{i+1} : ") + lib_data["bookNo"] = int(input("Enter the Number of book : ")) + lib_data["bname"] = input("Enter Name of the Book : ") + lib_data["price"] = int(input("Enter price of the Book : ")) + pickle.dump(lib_data, file) + file.close() + + +def show_books(): + file = open('library.dat', 'rb') + try: + while True: + data = pickle.load(file) + print(data) + except EOFError: + pass + file.close() + + +def search_book(): + file = open('library.dat', 'rb') + bookNo = int(input("Enter Book Number you want to Search : ")) + found = 0 + try: + while True: + data = pickle.load(file) + if data["bookNo"] == bookNo: + print("\nRecord Found : ") + print(data) + found = 1 + break + except EOFError: + pass + if found == 0: + print(f"Book-{bookNo} Not Found!") + file.close() + + +def update_booK(): + bdata1 = open("library.dat", "rb") + bdata2 = open("temp.dat", "ab") + bookNo = int(input("Enter Book Number to Update : ")) + try: + while True: + data = pickle.load(bdata1) + if data["bookNo"] == bookNo: + print(f"\nEnter New Details of Book-{bookNo} : ") + data["bookNo"] = int(input("Enter Number of Book : ")) + data["bname"] = input("Enter Name of Book : ") + data["price"] = int(input("Enter Price of Book : ")) + pickle.dump(data, bdata2) + print("Data Updated Successfully") + else: + pickle.dump(data, bdata2) + except EOFError: + pass + bdata1.close() + bdata2.close() + os.remove("library.dat") + os.rename("temp.dat", "library.dat") + + +def remove_book(): + bdata1 = open("library.dat", "rb") + bdata2 = open("temp.dat", "ab") + bookNo = int(input("Enter Book Number to Delete : ")) + try: + while True: + data = pickle.load(bdata1) + if data["bookNo"] == bookNo: + print(f"Book-{bookNo} Deleted Successfully.") + pass + else: + pickle.dump(data, bdata2) + except EOFError: + pass + bdata1.close() + bdata2.close() + os.remove("library.dat") + os.rename("temp.dat", "library.dat") + +while True: + print('\nOperations :\n 1 - Add Book Details.\n 2 - Show Book Details\n 3 - Update Book Details. ') + print(' 4 - Delete Book Detail.\n 5 - Search Book.\n 6 - Clock.\n 7 - EXIT.') + op = int(input("\nEnter Number to Choose Operation : ")) + if op == 1: + add_books() + elif op == 2: + print(f"\nBooks Details : ") + show_books() + elif op == 3: + update_booK() + elif op == 4: + remove_book() + elif op == 5: + search_book() + elif op == 6: + import time + live_time = time.strftime("%H:%M:%S") + print(f"\n| The Current timings are : {live_time} |") + elif op == 7: + print("Thanks for Using Library Management System") + print("Creators of Library Management System :\n " + "| Akash kumar Singh |") + break + else: + print("Please Choose CORRECT Operation!") + From bdaa4fba0817f5ef3f9a77c63d805bf1c1bf61a0 Mon Sep 17 00:00:00 2001 From: Akash Kumar Singh <57872097+akashkumarsingh612@users.noreply.github.com> Date: Mon, 28 Dec 2020 19:45:59 +0530 Subject: [PATCH 07/12] Update Airways Management System --- Airways Management System | 100 +++++++++++++++++++++----------------- 1 file changed, 56 insertions(+), 44 deletions(-) diff --git a/Airways Management System b/Airways Management System index 6d9e441..0fc40fd 100644 --- a/Airways Management System +++ b/Airways Management System @@ -2,6 +2,7 @@ Make Sure You've Installed Python Text to speech i.e. pyttsx3 If not then Open Command Prompt and type : pip install pyttsx3 Source Code : + # Airways Management System import pickle # we are using pickle bec it operates binary files (will increase performance of program). @@ -44,28 +45,34 @@ def write_data(): def show_data(): ''' it will Display all the Flights Data inside flight.dat file''' - try: - with open("flight.dat", "rb") as fdata: + say("Showing Flight Details") + with open('flight.dat', 'rb') as file: + try: while True: - print(f'{ pickle.load(fdata)}') - except Exception: - pass + data = pickle.load(file) + print(data) + except EOFError: + pass def del_data(): speak('Please Enter Flight Number to delete its DATA') flightNo = int(input("\nPlease Enter Flight Number to delete its DATA : ")) + fdata1 = open("flight.dat", "rb") + fdata2 = open("temp.dat", "ab") try: - with open("flight.dat", "rb") as fdata1: - with open("temp.dat", "ab") as fdata2: - data = pickle.load(fdata1) - if data["flightNo"] == flightNo: - pass - else: - pickle.dump(data, fdata2) - except Exception: - say("Error : There is no Data in flight.dat") - print("Error : There is no Data in flight.dat") + while True: + data = pickle.load(fdata1) + if data["flightNo"] == flightNo: + print(f"Flight-{flightNo} Deleted Successfully.") + say(f"Flight-{flightNo} Deleted Successfully.") + pass + else: + pickle.dump(data, fdata2) + except EOFError: + pass + fdata1.close() + fdata2.close() os.remove("flight.dat") os.rename("temp.dat", "flight.dat") @@ -78,12 +85,13 @@ def del_data(): except Exception: pass + def search(): - try: - with open('flight.dat', 'rb') as fdata: - speak(" Please Enter Flight Number to Search its Details") - fsearch = int(input("\nEnter Flight Number to Search : ")) - datafound = 0 + with open('flight.dat', 'rb') as fdata: + speak(" Please Enter Flight Number to Search its Details") + fsearch = int(input("\nEnter Flight Number to Search : ")) + datafound = 0 + try: while True: data = pickle.load(fdata) if data['flightNo'] == fsearch: @@ -92,37 +100,40 @@ def search(): print(f'Search Result : \n {data}') say(data) break - if datafound == 0: - speak(f'Details of flight-{fsearch} was NOT FOUND') - print(f"\n ! Details of flight-{fsearch} was NOT FOUND !") - except Exception: - print("Error : There is no Data in flight.dat") + except Exception: + print("Error : There is no Data in flight.dat") + if datafound == 0: + speak(f'Details of flight-{fsearch} was NOT FOUND') + print(f"\n ! Details of flight-{fsearch} was NOT FOUND !") def update_data(): - with open("flight.dat", "rb") as fdata: - with open("temp.dat", "wb") as fdata2: - speak("Enter Flight Number to Update") - flightNo = int(input("Enter Flight Number to Update : ")) - try: - while True: - data = pickle.load(fdata) - if data["flightNo"] == flightNo: - print("Enter Flight New Details : \n") - data["flightNo"] = int(input("Enter Flight Number : ")) - data["fname"] = input("Enter Flight's Name : ") - data["fare"] = int(input("Enter the Fare : ")) - pickle.dump(data, fdata2) - break - else: - pickle.dump(data, fdata2) - except EOFError: - pass + data1 = open("flight.dat", "rb") + data2 = open("temp.dat", "ab") + speak("Enter Flight Number to Update it") + flightNo = int(input("Enter Flight Number to Update : ")) + try: + while True: + data = pickle.load(data1) + if data["flightNo"] == flightNo: + speak(f"Enter New Details of Flight-{flightNo}") + print(f"\nEnter New Details of Flight-{flightNo} : ") + data["flightNo"] = int(input("Enter Flight Number : ")) + data["fname"] = input("Enter Flight's Name : ") + data["fare"] = int(input("Enter the Fare : ")) + pickle.dump(data, data2) + speak(f"Data of flight-{flightNo} Updated Successfully.") + print("Data Updated Successfully.") + else: + pickle.dump(data, data2) + except EOFError: + pass + data1.close() + data2.close() os.remove("flight.dat") os.rename("temp.dat", "flight.dat") - def flower(): import turtle turtle.penup() @@ -242,3 +253,4 @@ while True: else: speak("Hey, Please Choose the Correct Operations!") print("Please Choose CORRECT Operation!") + From 2276423165395102b9d56a1726167dc022cec33e Mon Sep 17 00:00:00 2001 From: Akash Kumar Singh <57872097+akashkumarsingh612@users.noreply.github.com> Date: Thu, 31 Dec 2020 17:53:23 +0530 Subject: [PATCH 08/12] Update Airways Management System --- Airways Management System | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Airways Management System b/Airways Management System index 0fc40fd..f701ef4 100644 --- a/Airways Management System +++ b/Airways Management System @@ -244,8 +244,8 @@ while True: elif op == 7: say("Thanks for Using Airways Management System") print("Thanks for Using Airways Management System") - say("Creators of this, Airways Management System are |Akash kumar Singh, |Rohit Kumar and Pawan Meena ") - print("Creators of Airways Management System :\n | Akash kumar Singh | Rohit kumar | Pawan Meena |") + say("Creators of this, Airways Management System are |Akash kumar Singh |") + print("Creators of Airways Management System :\n | Akash kumar Singh|") speak("Here's a Flower for you DEAR") flower() speak("See You Again! Bye Dear") From 65e8090295e053cc493be134b56a2c6fb96c5e9f Mon Sep 17 00:00:00 2001 From: Akash <57872097+cleverakash@users.noreply.github.com> Date: Mon, 4 Jan 2021 20:21:38 +0530 Subject: [PATCH 09/12] Update Airways Management System --- Airways Management System | 81 --------------------------------------- 1 file changed, 81 deletions(-) diff --git a/Airways Management System b/Airways Management System index f701ef4..1a4471b 100644 --- a/Airways Management System +++ b/Airways Management System @@ -133,85 +133,6 @@ def update_data(): os.remove("flight.dat") os.rename("temp.dat", "flight.dat") - -def flower(): - import turtle - turtle.penup() - turtle.left(90) - turtle.fd(200) - turtle.pendown() - turtle.right(90) - turtle.fillcolor("red") - turtle.begin_fill() - turtle.circle(10, 180) - turtle.circle(25, 110) - turtle.left(50) - turtle.circle(60, 45) - turtle.circle(20, 170) - turtle.right(24) - turtle.fd(30) - turtle.left(10) - turtle.circle(30, 110) - turtle.fd(20) - turtle.left(40) - turtle.circle(90, 70) - turtle.circle(30, 150) - turtle.right(30) - turtle.fd(15) - turtle.circle(80, 90) - turtle.left(15) - turtle.fd(45) - turtle.right(165) - turtle.fd(20) - turtle.left(155) - turtle.circle(150, 80) - turtle.left(50) - turtle.circle(150, 90) - turtle.end_fill() - turtle.left(150) - turtle.circle(-90, 70) - turtle.left(20) - turtle.circle(75, 105) - turtle.setheading(60) - turtle.circle(80, 98) - turtle.circle(-90, 40) - turtle.left(180) - turtle.circle(90, 40) - turtle.circle(-80, 98) - turtle.setheading(-83) - turtle.fd(30) - turtle.left(90) - turtle.fd(25) - turtle.left(45) - turtle.fillcolor("green") - turtle.begin_fill() - turtle.circle(-80, 90) - turtle.right(90) - turtle.circle(-80, 90) - turtle.end_fill() - turtle.right(135) - turtle.fd(60) - turtle.left(180) - turtle.fd(85) - turtle.left(90) - turtle.fd(80) - turtle.right(90) - turtle.right(45) - turtle.fillcolor("green") - turtle.begin_fill() - turtle.circle(80, 90) - turtle.left(90) - turtle.circle(80, 90) - turtle.end_fill() - turtle.left(135) - turtle.fd(60) - turtle.left(180) - turtle.fd(60) - turtle.right(90) - turtle.circle(200, 60) - turtle.done() - - speak_one_time = 0 speak_one = 0 while True: @@ -246,8 +167,6 @@ while True: print("Thanks for Using Airways Management System") say("Creators of this, Airways Management System are |Akash kumar Singh |") print("Creators of Airways Management System :\n | Akash kumar Singh|") - speak("Here's a Flower for you DEAR") - flower() speak("See You Again! Bye Dear") break else: From d63357fd02c46623f6965bd129db1faf21f79677 Mon Sep 17 00:00:00 2001 From: Akash <57872097+cleverakash@users.noreply.github.com> Date: Fri, 15 Jan 2021 03:05:01 +0530 Subject: [PATCH 10/12] AirWays Management System using MySQL Connectivity --- aws.py | 130 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 130 insertions(+) create mode 100644 aws.py diff --git a/aws.py b/aws.py new file mode 100644 index 0000000..bb13060 --- /dev/null +++ b/aws.py @@ -0,0 +1,130 @@ +# Airways Management System using MySql Connector + +''' +Make Sure you have installed mysql.connector modules +- Python My SQL Connector - pip install mysql-connector +''' + +import mysql.connector + + +sqlpswd = input("Enter SQL USER Password : ") + +''' Since the User name of most SQL users are same i.e. 'root' ''' +flightDB = mysql.connector.connect(host='localhost', user='root', passwd=sqlpswd) + +# Fetching the Databases in our Program +cursor = flightDB.cursor() + +# Will Create Database Flight If it's not created before +try: + cursor.execute('CREATE DATABASE flight') +except: + pass + +# Using Database flight +cursor.execute('USE flight') + +# Creating Table of Flight's Data +try: + cursor.execute('CREATE TABLE flightData(flightNo INT, fName VARCHAR(20), fare INT)') +except: + pass + +line = "----------------------------------------------------------------" +def write_data(): + ''' It will add New Details of Flights in table flightData''' + No_Of_flight = int(input(f"\n{line}\nEnter the Number of Flights you want to insert : ")) + for num in range(No_Of_flight): + print(f'{line}\nEnter the Details of {num+1}-Flight : \n') + flightNo = int(input(f'Enter flight Number : ')) + fName = input(f'Enter Name of flight-{flightNo} : ') + fare = input(f'Enter Fare of {fName}-{flightNo} : ') + cursor.execute(f"INSERT INTO flightData VALUES ({flightNo}, '{fName}', {fare})") + flightDB.commit() + print(line) + + +def show(): + ''' It will show all the Contents in table flightData''' + try: + cursor.execute('SELECT * FROM flightData') + data = cursor.fetchall() + print(f"\n{line}\nDetails of Flight : ") + for flights in data: + print(' ', flights) + print(line) + except Exception: + print("Empty Database! Please Insert Details of Flight using 1st Operation.") + + +def delete(): + '''To delete some details of particular flight''' + flightNo = int(input(f"\n{line}\nPlease Enter Flight Number to delete its Data : ")) + try: + cursor.execute(f'DELETE FROM flightData WHERE flightNo={flightNo}') + print(f'{line}\nDetails of Flight-{flightNo}, deleted Successfully.') + flightDB.commit() + print(line) + except Exception: + print(f'Details of Flight-{flightNo} was Not Found!') + + +def search(): + '''It'll Search and return a particular Flight details ''' + flightNo = int(input(f"\n{line}\nPlease Enter Flight Number to Search : ")) + try: + cursor.execute(f'SELECT * FROM flightData WHERE flightNo={flightNo}') + data = cursor.fetchall() + print(f'\n{line}\nDetails of Flight-{flightNo} :\n {data} \n{line}') + except Exception: + print(f'Details of Flight-{flightNo} was Not Found!') + + +def updateData(): + '''It'll Update the details of particular flight''' + oldfNo = int(input(f"\n{line}\nEnter Flight Number to Update its detail : ")) + try: + print(f'{line}\nEnter the New Details of Flight-{oldfNo} : ') + flightNo = int(input(f'Enter flight Number :')) + cursor.execute(f'UPDATE flightData SET flightNo={flightNo} WHERE flightNo={oldfNo}') + fName = input(f'Enter Name of flight-{flightNo} : ') + cursor.execute(f'UPDATE flightData SET fName="{fName}" WHERE flightNo={flightNo}') + fare = input(f'Enter Fare of {fName}-{flightNo} : ') + cursor.execute(f'UPDATE flightData SET fare={fare} WHERE flightNo={flightNo}') + flightDB.commit() + print(f'{line}\nDetails of {fName}-{flightNo} Updated Successfully.\n{line}') + except Exception: + print(f'Details of Flight-{oldfNo} was Not Found!') + + +while True: + print('\nOperations :\n 1 - Add Flight Details.\n 2 - Show Flight Details\n 3 - Update Flight Details. ') + print(' 4 - Delete Flight Detail.\n 5 - Search Flights.\n 6 - Clock.\n 7 - EXIT.') + op = int(input("\nEnter Number to Choose Operation : ")) + if op == 1: + write_data() + elif op == 2: + show() + elif op == 3: + updateData() + elif op == 4: + delete() + elif op == 5: + search() + elif op == 6: + import time + live_time = time.strftime("%H:%M:%S") + print(f"\n{line}\nThe Current timings are : {live_time} \n{line}\n") + elif op == 7: + print(f"\n{line}\nThanks for Using Airways Management System.\n") + print(f"Creators of Airways Management System :\n | Akash kumar Singh | Rohit kumar | Pawan Meena | \n{line}") + break + else: + print("Please Choose CORRECT Operation!") + +flightDB.close() + + + + From a138cd3b46a60158ff58fbd943859a8526eda861 Mon Sep 17 00:00:00 2001 From: Akash <57872097+cleverakash@users.noreply.github.com> Date: Fri, 15 Jan 2021 03:43:11 +0530 Subject: [PATCH 11/12] Airways_Management_System This is Airways Management System which can speak also and will connect to MySQL to stores and handle Databases. --- AirwaysManagementSystem.py | 161 +++++++++++++++++++++++++++++++++++++ 1 file changed, 161 insertions(+) create mode 100644 AirwaysManagementSystem.py diff --git a/AirwaysManagementSystem.py b/AirwaysManagementSystem.py new file mode 100644 index 0000000..551179c --- /dev/null +++ b/AirwaysManagementSystem.py @@ -0,0 +1,161 @@ +# Airways Management System + +''' +Make Sure you have installed two modules : +1. Python text-to-speech - pip install pyttsx3 +2. Python My SQL Connector - pip install mysql-connector +''' + +import mysql.connector # it'll connect python to MySQL RDMS by which we can access our Databases. +import pyttsx3 # this is Python text-to-speech which gives a voice to our Airways Management System. + + +def speak(line): + '''it will give a female voice to Every line given as argument(parameter)''' + voice_id = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Speech\Voices\Tokens\TTS_MS_EN-US_ZIRA_11.0" + voice = pyttsx3.init() + voice.setProperty('voice', voice_id) + voice.say(line) + voice.runAndWait() + + +speak("Enter Sql USER Password to get Started & if you don't know the password just press Enter") +sqlpswd = input("Enter SQL USER Password : ") + +''' Since the User name of most SQL users are same i.e. 'root' ''' +flightDB = mysql.connector.connect(host='localhost', user='root', passwd=sqlpswd) + +# Fetching the Databases in our Program +cursor = flightDB.cursor() + +# Will Create Database Flight If it's not created before +try: + cursor.execute('CREATE DATABASE flight') +except: + pass + +# Using Database flight +cursor.execute('USE flight') + +# Creating Table of Flight's Data +try: + cursor.execute('CREATE TABLE flightData(flightNo INT, fName VARCHAR(20), fare INT)') +except: + pass + +line = "----------------------------------------------------------------" +def write_data(): + ''' It will add New Details of Flights in table flightData''' + speak('Enter the Number of Flights you want to insert in Database') + No_Of_flight = int(input(f"\n{line}\nEnter the Number of Flights you want to insert : ")) + for num in range(No_Of_flight): + speak(f'Enter the Details of {num+1}-Flight') + print(f'{line}\nEnter the Details of {num+1}-Flight : \n') + flightNo = int(input(f'Enter flight Number : ')) + fName = input(f'Enter Name of flight-{flightNo} : ') + fare = input(f'Enter Fare of {fName}-{flightNo} : ') + cursor.execute(f"INSERT INTO flightData VALUES ({flightNo}, '{fName}', {fare})") + flightDB.commit() + print(line) + + +def show(): + ''' It will show all the Contents in table flightData''' + try: + speak('Showing the Details of Flights') + cursor.execute('SELECT * FROM flightData') + data = cursor.fetchall() + print(f"\n{line}\nDetails of Flight : ") + for flights in data: + print(' ', flights) + print(line) + except Exception: + print("Empty Database! Please Insert Details of Flight using 1st Operation.") + + +def delete(): + '''To delete some details of particular flight''' + speak('Please Enter Flight Number to delete its Data : ') + flightNo = int(input(f"\n{line}\nPlease Enter Flight Number to delete its Data : ")) + try: + cursor.execute(f'DELETE FROM flightData WHERE flightNo={flightNo}') + speak(f'Details of Flight-{flightNo}, deleted Successfully') + print(f'{line}\nDetails of Flight-{flightNo}, deleted Successfully.') + flightDB.commit() + print(line) + except Exception: + print(f'Details of Flight-{flightNo} was Not Found!') + + +def search(): + '''It'll Search and return a particular Flight details ''' + speak("Please Enter Flight Number to Search : ") + flightNo = int(input(f"\n{line}\nPlease Enter Flight Number to Search : ")) + try: + cursor.execute(f'SELECT * FROM flightData WHERE flightNo={flightNo}') + data = cursor.fetchall() + print(f'\n{line}\nDetails of Flight-{flightNo} :\n {data} \n{line}') + except Exception: + print(f'Details of Flight-{flightNo} was Not Found!') + + +def updateData(): + '''It'll Update the details of particular flight''' + speak('Enter Flight Number to Update its detail :') + oldfNo = int(input(f"\n{line}\nEnter Flight Number to Update its detail : ")) + try: + speak(f'Enter the New Details of Flight-{oldfNo} :') + print(f'{line}\nEnter the New Details of Flight-{oldfNo} : ') + flightNo = int(input(f'Enter flight Number :')) + cursor.execute(f'UPDATE flightData SET flightNo={flightNo} WHERE flightNo={oldfNo}') + fName = input(f'Enter Name of flight-{flightNo} : ') + cursor.execute(f'UPDATE flightData SET fName="{fName}" WHERE flightNo={flightNo}') + fare = input(f'Enter Fare of {fName}-{flightNo} : ') + cursor.execute(f'UPDATE flightData SET fare={fare} WHERE flightNo={flightNo}') + flightDB.commit() + speak(f'Details of {fName}-{flightNo} Updated Successfully.') + print(f'{line}\nDetails of {fName}-{flightNo} Updated Successfully.\n{line}') + except Exception: + print(f'Details of Flight-{oldfNo} was Not Found!') + + +speak_one_time = 0 +speak_one = 0 +while True: + if speak_one == 0: + speak("Enter Number to choose specific operation you want to perform") + speak_one = 1 + print('\nOperations :\n 1 - Add Flight Details.\n 2 - Show Flight Details\n 3 - Update Flight Details. ') + print(' 4 - Delete Flight Detail.\n 5 - Search Flights.\n 6 - Clock.\n 7 - EXIT.') + if speak_one_time == 0: + speak("1 for Adding Flight Details, 2 for Displaying flight details, 3 to Update flight details" + "4 for Deleting flight details, 5 to Search Flights, 6 to know current timings, and 7 for Exit") + speak_one_time = 1 + + op = int(input("\nEnter Number to Choose Operation : ")) + if op == 1: + write_data() + elif op == 2: + show() + elif op == 3: + updateData() + elif op == 4: + delete() + elif op == 5: + search() + elif op == 6: + import time + live_time = time.strftime("%H:%M:%S") + speak(f"The Current timings are : {live_time}") + print(f"\n{line}\nThe Current timings are : {live_time} \n{line}\n") + elif op == 7: + speak('Thanks for Using Airways Management System') + print(f"\n{line}\nThanks for Using Airways Management System.\n") + speak("Creators of this, Airways Management System are Akash kumar Singh, Rohit Kumar and Pawan Meena ") + print(f"Creators of Airways Management System :\n | Akash kumar Singh | Rohit kumar | Pawan Meena | \n{line}") + break + else: + speak("Please Choose CORRECT Operation!") + print("Please Choose CORRECT Operation!") + +flightDB.close() From 389610d3e6240986ae2a9796896014f5b803be20 Mon Sep 17 00:00:00 2001 From: Akash <57872097+cleverakash@users.noreply.github.com> Date: Thu, 18 Feb 2021 22:09:40 +0530 Subject: [PATCH 12/12] Update AirwaysManagementSystem.py --- AirwaysManagementSystem.py | 93 ++++++++++++++++++++++---------------- 1 file changed, 53 insertions(+), 40 deletions(-) diff --git a/AirwaysManagementSystem.py b/AirwaysManagementSystem.py index 551179c..30102e7 100644 --- a/AirwaysManagementSystem.py +++ b/AirwaysManagementSystem.py @@ -22,8 +22,19 @@ def speak(line): speak("Enter Sql USER Password to get Started & if you don't know the password just press Enter") sqlpswd = input("Enter SQL USER Password : ") -''' Since the User name of most SQL users are same i.e. 'root' ''' -flightDB = mysql.connector.connect(host='localhost', user='root', passwd=sqlpswd) +try: + ''' Since the User name of most SQL users are same i.e. 'root' we'll also it''' + flightDB = mysql.connector.connect(host='localhost', user='root', passwd=sqlpswd) +except Exception: + speak("You've entered wrong sql password try again") + print("Wrong Password try again ->") + pswd = input(" Enter SQL USER Password : ") + try: + flightDB = mysql.connector.connect(host='localhost', user='root', passwd=pswd) + except Exception: + speak("You've Again entered wrong SQL password please remember it and Try agail Later!") + print("Brother Focus and Try Later! Go Relax ;)") + quit() # Fetching the Databases in our Program cursor = flightDB.cursor() @@ -44,6 +55,7 @@ def speak(line): pass line = "----------------------------------------------------------------" + def write_data(): ''' It will add New Details of Flights in table flightData''' speak('Enter the Number of Flights you want to insert in Database') @@ -119,43 +131,44 @@ def updateData(): print(f'Details of Flight-{oldfNo} was Not Found!') -speak_one_time = 0 -speak_one = 0 -while True: - if speak_one == 0: - speak("Enter Number to choose specific operation you want to perform") - speak_one = 1 - print('\nOperations :\n 1 - Add Flight Details.\n 2 - Show Flight Details\n 3 - Update Flight Details. ') - print(' 4 - Delete Flight Detail.\n 5 - Search Flights.\n 6 - Clock.\n 7 - EXIT.') - if speak_one_time == 0: - speak("1 for Adding Flight Details, 2 for Displaying flight details, 3 to Update flight details" - "4 for Deleting flight details, 5 to Search Flights, 6 to know current timings, and 7 for Exit") - speak_one_time = 1 - - op = int(input("\nEnter Number to Choose Operation : ")) - if op == 1: - write_data() - elif op == 2: - show() - elif op == 3: - updateData() - elif op == 4: - delete() - elif op == 5: - search() - elif op == 6: - import time - live_time = time.strftime("%H:%M:%S") - speak(f"The Current timings are : {live_time}") - print(f"\n{line}\nThe Current timings are : {live_time} \n{line}\n") - elif op == 7: - speak('Thanks for Using Airways Management System') - print(f"\n{line}\nThanks for Using Airways Management System.\n") - speak("Creators of this, Airways Management System are Akash kumar Singh, Rohit Kumar and Pawan Meena ") - print(f"Creators of Airways Management System :\n | Akash kumar Singh | Rohit kumar | Pawan Meena | \n{line}") - break - else: - speak("Please Choose CORRECT Operation!") - print("Please Choose CORRECT Operation!") +if __name__=="__main__": + speak_one_time = 0 + speak_one = 0 + while True: + if speak_one == 0: + speak("Enter Number to choose specific operation you want to perform") + speak_one = 1 + print('\nOperations :\n 1 - Add Flight Details.\n 2 - Show Flight Details\n 3 - Update Flight Details. ') + print(' 4 - Delete Flight Detail.\n 5 - Search Flights.\n 6 - Clock.\n 7 - EXIT.') + if speak_one_time == 0: + speak("1 for Adding Flight Details, 2 for Displaying flight details, 3 to Update flight details" + "4 for Deleting flight details, 5 to Search Flights, 6 to know current timings, and 7 for Exit") + speak_one_time = 1 + + op = int(input("\nEnter Number to Choose Operation : ")) + if op == 1: + write_data() + elif op == 2: + show() + elif op == 3: + updateData() + elif op == 4: + delete() + elif op == 5: + search() + elif op == 6: + import time + live_time = time.strftime("%H:%M:%S") + speak(f"The Current timings are : {live_time}") + print(f"\n{line}\nThe Current timings are : {live_time} \n{line}\n") + elif op == 7: + speak('Thanks for Using Airways Management System') + print(f"\n{line}\nThanks for Using Airways Management System.\n") + speak("Creators of this, Airways Management System are Akash kumar Singh, Rohit Kumar and Pawan Meena ") + print(f"Creators of Airways Management System :\n | Akash kumar Singh | Rohit kumar | Pawan Meena | \n{line}") + break + else: + speak("Please Choose CORRECT Operation!") + print("Please Choose CORRECT Operation!") flightDB.close()