Professional Documents
Culture Documents
Aarohan Subedi
Aarohan Subedi
I confirm that I understand my coursework needs to be submitted online via Google Classroom under the
relevant module page before the deadline in order for my assignment to be accepted and marked. I am
fully aware that late submissions will be treated as non-submission and a marks of zero will be awarded.
AAROHAN SUBEDI 1
CS4051NI Fundamentals of Computing
TABLE OF CONTENTS
1 INTRODUCTION.......................................................................................................... 5
1.1 Detail of the project ............................................................................................ 5
1.2 Goals And Objectives......................................................................................... 5
2. Discussion And Analysis ............................................................................................. 6
2.1 Algorithm:............................................................................................................... 6
2.2 Flowchart ............................................................................................................... 9
2.3 Pseudocode......................................................................................................... 10
Pseudocode for rent.py.............................................................................................. 10
Pseudocode for display.py......................................................................................... 14
Pseudocode for main.py ............................................................................................ 16
Pseudocode for return.py .......................................................................................... 18
2.4 Data Structures.................................................................................................... 22
3. Program .................................................................................................................... 24
3.1. Testing................................................................................................................ 25
3.2 File....................................................................................................................... 30
3.3 Txt file.................................................................................................................. 31
4. Conclusion ................................................................................................................ 32
5. Appendix ................................................................................................................... 33
Codes of main.py....................................................................................................... 33
Codes of rent.py ........................................................................................................ 34
Codes of return.py .................................................................................................... 38
Codes of display.py ................................................................................................... 42
Codes of returnfunc ................................................................................................... 45
Codes of returnfunc ................................................................................................... 48
BIBILOGRAPHY............................................................................................................ 51
Originality Report....................................................................................................... 52
AAROHAN SUBEDI 2
CS4051NI Fundamentals of Computing
AAROHAN SUBEDI 3
CS4051NI Fundamentals of Computing
LIST OF FIGURES
AAROHAN SUBEDI 4
CS4051NI Fundamentals of Computing
LIST OF TABLES
AAROHAN SUBEDI 5
CS4051NI Fundamentals of Computing
1 INTRODUCTION
This project is about a tailor-made rental application according to the needs of the
course for the user or customer. Using the python programming language coursework
was completed. This project generally covers the entire renting process for the all items.
In this project, we can use the preferred display, loan and return option of the costume.
The text file named costume.txt is imported to the py file. To display the costume in text
format, to rent it and return it by creating a new text file.
This course is assigned us to create our own rental app using the python programming
language. The main purpose of this project is to bring together what we have learned in
this module this semester and create a costume rental app.
This report contains the algorithm, flowchart and pseudocode of the costume rental app
which we created using the python programming language, and a summary of the entire
AAROHAN SUBEDI 6
CS4051NI Fundamentals of Computing
path of creating the program plus testing it . The program records the data of all
costumes in the app, their quantity, prices, rental date, etc. The program was created
for renting costumes.
For easy reference, the algorithm and pseudocode are written and a flowchart is
created in this report. The "list" data structure is chosen to represent the information to
be processed by the program. A list comprehension and indexing method is also used
to manage the data in the program.
The program is divided into five different modules for our convenience
i.e. Main, Return,Borrow,DateTime,Split.
The user can select one of four options: View, Borrow, Return, Quit. The selection
screen lists all the costumes that can be rented from the costume rental app. Borrowing
option is used to borrow a costume from a borrowing application where the borrower's
information is stored. The return option is for returning borrowed costumes, and there is
also the ability to specify a fee if the return of a borrowed costume is delayed beyond a
specified time, allowing the borrower to be charged. After selecting the option to exit the
program, a thank you message will be displayed.
This software uses a "List" data structure to keep track of all the information about the
costumes that are accessible in the store or rental application. Our application accesses
the "stock.txt" file, which includes all the information about the costumes that are
accessible in the library, and modifies it in response to changes in the store's stock
levels.
AAROHAN SUBEDI 7
CS4051NI Fundamentals of Computing
2.1 Algorithm:
Algorithm is a step-by-step procedure, which defines a set of instructions to be executed
in a certain order to get the desired output. Algorithms are generally created
independent of underlying languages, i.e. an algorithm can be implemented in more
than one programming language (tuitorialpoint, 2022).
OBJECTIVE FUNCTION
STEPS:
Type 3 to exit.
4. que 0:
b) Open “costumes.txt” .
AAROHAN SUBEDI 8
CS4051NI Fundamentals of Computing
g) Does the customer want to rent another costume as well?? .Please enter 'Y' if
the customer wants to rent another costume else provide any other value:
i) If no then note invoice will be generated including name of the customer, date
and time, Total Price, Items rented and brands of the item.
j) Exit
6. que 2
e) How many days you rented the costume? If rented less than 5days then,
f) Enter the name of the customer and if not then, late return penalty fine is
added.
g) fine = 1.5*day/s
AAROHAN SUBEDI 9
CS4051NI Fundamentals of Computing
i) text file with the total cost is generated with name of the customer, date and
time of return, total fine, Items rented and brand of the costume.
j) End
7. que 3
AAROHAN SUBEDI 10
CS4051NI Fundamentals of Computing
2.2 Flowchart
AAROHAN SUBEDI 11
CS4051NI Fundamentals of Computing
2.3 Pseudocode
IMPORT DateTime
IMPORT random
IMPORT views
IMPORT rental_Fun
define rent_costume()
CALL views.Rent()
CALL rental_Fun.catalog()
CALL rental_Fun.dictionary_rent()
IF
INPUT > 0
CALL views.costume_available()
INPUT Quantity
INPUT Customer_name
INITALIZE Date_Time
AAROHAN SUBEDI 12
CS4051NI Fundamentals of Computing
IF rent_more is true
CALL views.Rent()
CALL rental_Fun.catalog()
CALL views.costume_available()
Ask quantity
AAROHAN SUBEDI 13
CS4051NI Fundamentals of Computing
rental_Fun.stock_costume(dictionaryCostume)
SET price as rental_Fun.Total_price(dictionaryCostume + booked items + price
PRINT
“++++++++++++++++++++++++++++++++++++++++++++”
PRINT
“+++++++++++++++++++++++++++++++++++++++++++++”
END IF
ELSE
BREAK
AAROHAN SUBEDI 14
CS4051NI Fundamentals of Computing
DEFINE bill.write
BREAK
END ELSE
ELSE
CALL views.costume_unavailable()
END ELSE
AAROHAN SUBEDI 15
CS4051NI Fundamentals of Computing
DEFINE welcome()
PRINT “++++++++++++++++++++++++++++++++++++++++++++”
PRINT “ Welcome to Costume Rental Application” PRINT
“+++++++++++++++++++++++++++++++++++++++++++++”
DEFINE options()
DEFINE Invalid()
DEFINE Rent()
PRINT “++++++++++++++++++++++++++++++”
PRINT “++++++++++++++++++++++++++++++”
DEFINE Invalid_option()
PRINT “+++++++++++++++++++++++++++++++++++++++++++++++”
PRINT “ Invalid option!!! Please re-enter the option. ”
AAROHAN SUBEDI 16
CS4051NI Fundamentals of Computing
PRINT “+++++++++++++++++++++++++++++++++++++++++++++++”
DEFINE costume_available()
PRINT “++++++++++++++++++++++++++++++”
PRINT “++++++++++++++++++++++++++++++”
DEFINE costume_unavailable()
PRINT “++++++++++++++++++++++++++++++++”
PRINT “++++++++++++++++++++++++++++++++++”
DEFINE valid()
PRINT “++++++++++++++++++++++++++++++++++++++++++++++”
PRINT “ Please provide a valid costume ID!!! ”
PRINT “Invalid_input”
PRINT “++++++++++++++++++++++++++++++++++++++++++++++”
PRINT “++++++++++++++++++++++++++++++++++++++++++++++++”
PRINT “ Invalid input!!! Please re-enter correct value ” PRINT
“++++++++++++++++++++++++++++++++++++++++++++++++”
DEFNE valid_quantity()
PRINT “+++++++++++++++++++++++++++++++++++++++++++”
PRINT “ Please provide a valid quantity!!! ”
PRINT “++++++++++++++++++++++++++++++++++++++++++++”
DEFINE more_quantity()
AAROHAN SUBEDI 17
CS4051NI Fundamentals of Computing
PRINT “++++++++++++++++++++++++++++++++++++++++++++++++”
PRINT “ Quantity provided is greater than what we have in stock ” PRINT
“++++++++++++++++++++++++++++++++++++++++++++++++”
DEFINE Return()
PRINT “++++++++++++++++++++++++++++++++”
PRINT “++++++++++++++++++++++++++++++++”
DEFINE Exit()
IMPORT Rent
IMPORT Return
IMPORT views
CALL views.welcome()
while(True):
function views.option()
TRY:
END TRY
AAROHAN SUBEDI 18
CS4051NI Fundamentals of Computing
EXCEPT:
CALL views.Invalid_Options()
CALL views.options()
IF que is 0
CALL Rent.rent_costume()
END IF
ELIF que is 1
CALL Rent.rent_costume()
END ELIF
ELIF que is 2
CALL Return.return_costume()
END ELIF
ELIF que is 3
CALL views.Exit()
END ELIF
ELSE
CALL views.Invalid()
END EXCEPT
AAROHAN SUBEDI 19
CS4051NI Fundamentals of Computing
IMPORT DateTime
IMPORT random
IMPORT views
IMPORT rental_Fun
def rent_costume():
CALL views.Rent()
IF
Input > 0
AAROHAN SUBEDI 20
CS4051NI Fundamentals of Computing
IMPORT datetime
IMPORT random
IMPORT views
IMPORT return_Fun
DEFINE return_costume():
CALL views.Return()
CALL rental_Fun.dectionary_return()
SET dictionaryCostume =
return_Fun.deictionary_return() SET returnCostumeID =
return_Fun.valid_costume_ID() SET rented_costumes =
[]
SET items_brand = [ ]
If input is true
ASK quantity
BREAK
PRINT dictionarycostume
ASK rented time
If input > 5
AAROHAN SUBEDI 21
CS4051NI Fundamentals of Computing
END IF
ELSE
SET fine = 0
CALL return_Fun.stock_costume(dictionarycostume)
CALL return_Fun.stock_costume(dictionarycostume)
PRINT “++++++++++++++++++++++++++++++++++++++++++++++++++++++++”
PRINT “Have the customer rented another costume as well??” ASK if the customer
wants to return more
SET returnMORE = input “Please enter Y if want to return more”
While loop is true
IF returnMORE is equal to Y
CALL views.Return()
CALL rent_Fun.dectionary_return()
AAROHAN SUBEDI 22
CS4051NI Fundamentals of Computing
SET dictionaryCostume =
return_Fun.deictionary_return() SET returnCostumeID =
return_Fun.valid_costume_ID() SET rented_costumes =
[]
SET items_brand = [ ]
If input is true
ASK quantity
BREAK
PRINT dictionarycostume
If input > 5
END IF
ELSE
SET fine = 0
AAROHAN SUBEDI 23
CS4051NI Fundamentals of Computing
CALL returnFunc.stock_costume(dictionarycostume)
CALL return_Fun.stock_costume(dictionarycostume)
PRINT “++++++++++++++++++++++++++++++++++++++++++++++++++++++++”
PRINT “Have the customer rented another costume as well??” ASK if the customer
wants to return more
SET returnMORE = input “Please enter Y if want to return more”
END IF
ELSE
PRINT
“====================================================”
PRINT “ Bill Details ”
PRINT
“====================================================”
PRINT “****************************************************”
PRINT “Name of Customer:” + customer_name
BREAK
AAROHAN SUBEDI 24
CS4051NI Fundamentals of Computing
BREAK
BREAK
BREAK
BREAK
PRINT
“+++++++++++++++++++++++++++++++++++++++++++++++++++”
PRINT “| Return Details Bill has been generated. |”
PRINT
“+++++++++++++++++++++++++++++++++++++++++++++++++++”
BREAK
CALL bill.write()
BREAK
AAROHAN SUBEDI 25
CS4051NI Fundamentals of Computing
BREAK
BREAK
PRINT “==============================================”
CLOSE bill.write()
While loop is false
END ELSE
AAROHAN SUBEDI 26
CS4051NI Fundamentals of Computing
Each data structure provides a precise way to classify data so that it can be accessed
efficiently depending on the use case. Python's standard library comes with an
extensive set of data structures.
Python allows a variety of data types such as integer, text, boolean, and float. Here are
some of the types and data structures used to create applications which stores and also
manipulate the data and perform different actions on it.
This Program stores costume name, brand, quantity and cost values in a list. Values
can be added or removed from the list as the library's inventory changes. Effective use
of the built-in extend() and append() techniques of some components of the curriculum.
Integer: This is a Python data type containing integers. Numbers are used throughout
the program in a variety of contexts. When a user selects a book to borrow, return, or
view. When collecting suggestions for books to borrow. Additionally, it is used to hold
the number of books in the quantity[index] variable.
AAROHAN SUBEDI 27
CS4051NI Fundamentals of Computing
Float: It is a data type that stores the decimal values in the program. It is used to store
the total cost price of the costumes in the variable total.
Boolean: It is a data type that stores two values that is either true or false. It is used in
the program for storing variables for loops like success and to check the given
condition.
String: This a data type that stores values which are in texts. It stores any character as
long as it is encoded with . Printed messages in the program use string data type and
various operations like choices of the users like yes and no are also encoded with the
string data type.
AAROHAN SUBEDI 28
CS4051NI Fundamentals of Computing
3. Program
This application consists of the costumes rental system. This application or utility is
made to lease and go back a dress thru application.
This python report imports a few python documents and shows lease, go back and go
out this system. It additionally shows the records that is in costumes.txt report as study
mode. Main.py python report is the principle report that allows you to run at once and
we are able to open in any platform with main.py report. After starting a main.py report
this system will run with welcome message withinside the shell. This python report
consists of all of the strategies that is described with the aid of using the assist of def
keyword. After calling the strategies of view.py with the aid of using other .py report.This
python report consists of go back the invoice information with date, time, call of the
costumer brands, exceptional and total. It will go back after the lease of the gown. Fine
can be charged after go back of the gown if the go back days is extra than 5days.This
python report is blanketed all of the strategies and manner to lease the costumes. At
first we needed to pick the range of gown we need to lease and the amount of the gown
. And in addition to the call of the customer. We also can lease extra costumes as
according to the wishes and needs of the costumer
3.1. Testing
The testing process is carried out to check the program is running as expected and to
find any bugs and correct them.
TEST 1
AAROHAN SUBEDI 29
CS4051NI Fundamentals of Computing
AAROHAN SUBEDI 30
CS4051NI Fundamentals of Computing
TEST 2
AAROHAN SUBEDI 31
CS4051NI Fundamentals of Computing
TEST 3
AAROHAN SUBEDI 32
CS4051NI Fundamentals of Computing
AAROHAN SUBEDI 33
CS4051NI Fundamentals of Computing
AAROHAN SUBEDI 34
CS4051NI Fundamentals of Computing
3.2 File
TEST 4
AAROHAN SUBEDI 35
CS4051NI Fundamentals of Computing
AAROHAN SUBEDI 36
CS4051NI Fundamentals of Computing
AAROHAN SUBEDI 37
CS4051NI Fundamentals of Computing
AAROHAN SUBEDI 38
CS4051NI Fundamentals of Computing
AAROHAN SUBEDI 39
CS4051NI Fundamentals of Computing
4. Conclusion
This curriculum required a lot of time and effort. We had to address some issues and
bugs while completing this course. There was a lot of research done on the Internet and
in books about Python. Lecture slides were also very helpful.
For this assignment, we had to construct a Python-based costume rental app. I have
never used python before and this is my first time dealing with python and this project
taught me to create a program in python.
This coursework was very difficult to complete. I pointed out earlier that I knew nothing
about the subject. I found this coursework difficult to complete. However, with the help
of algorithms, pseudocode, flowcharts, research, and module his ladder, I was able to
easily complete this coursework.
While completing this course, I faced variety of problems, but with the help of my friend
and the module leader, I was able to fix them. I am familiar with this curriculum using
Python principles, functions, implementations, lists, and many other things.
This project was to be submitted effectively and carefully by August 26, 2022. The
purpose of this work is to make an app which rents customes. A lot of research was
also done to make this project successful.
AAROHAN SUBEDI 40
CS4051NI Fundamentals of Computing
5. Appendix
Main.py
import Rent
import Return
import views
views.welcome()
continueLoop = True
while continueLoop == True:
views.options()
continueCorrectOption = False
while continueCorrectOption == False:
try:
que = int(input("Enter a option: "))
continueCorrectOption = True
except:
views.invalid_options()
views.options()
if que == 0:
file=open("costumes.txt","r")
print(file.read())
file.close()
Rent.rent_costume()
elif que ==1:
Rent.rent_costume()
elif que == 2:
Return.return_costume()
elif que == 3:
views.Exit()
continueLoop = False
AAROHAN SUBEDI 41
CS4051NI Fundamentals of Computing
else:
views.Invalid()
AAROHAN SUBEDI 42
CS4051NI Fundamentals of Computing
Rent.py
import datetime
import random
import views
import rental_Fun
def rent_costume():
views.Rent()
rental_Fun.catalog()
rental_Fun.dictionary_rent()
dictionaryCostume = rental_Fun.dictionary_rent()
rentCostumeID = rental_Fun.valid_costume_ID()
rented_costumes = []
items_brand = []
if int(dictionaryCostume[rentCostumeID][3]) > 0:
views.costume_available()
net = rental_Fun.quantity(int(dictionaryCostume[rentCostumeID][3]))
dictionaryCostume[rentCostumeID][3] = int(dictionaryCostume[rentCostumeID][3])- net
print(dictionaryCostume)
price = rental_Fun.Total_price(dictionaryCostume,net,rentCostumeID)
rented_costumes.append(dictionaryCostume[rentCostumeID][0])
rental_Fun.stock_costume(dictionaryCostume)
items_brand.append(dictionaryCostume[rentCostumeID][1])
AAROHAN SUBEDI 43
CS4051NI Fundamentals of Computing
rental_Fun.stock_costume(dictionaryCostume)
print()
print("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++++++")
print("Does the customer want to rent another costume as well??")
rentMORE = input("Please enter 'Y' if the customer wants to rent another costume else
provide any other value: ").upper()
print("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++++++")
loop = True
while loop == True:
if rentMORE == "Y":
views.Rent()
rental_Fun.catalog()
dictionaryCostume = rental_Fun.dictionary_rent()
rentCostumeID = rental_Fun.valid_costume_ID()
if int(dictionaryCostume[rentCostumeID][3]) > 0:
views.costume_available()
net = rental_Fun.quantity(int(dictionaryCostume[rentCostumeID][3]))
dictionaryCostume[rentCostumeID][3] =
int(dictionaryCostume[rentCostumeID][3]) - net
print(dictionaryCostume)
rented_costumes.append(dictionaryCostume[rentCostumeID][0])
rental_Fun.stock_costume(dictionaryCostume)
AAROHAN SUBEDI 44
CS4051NI Fundamentals of Computing
items_brand.append(dictionaryCostume[rentCostumeID][1])
rental_Fun.stock_costume(dictionaryCostume)
print()
print("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++++++")
print("Does the customer want to rent another costume as well??")
rentMORE = input("Please enter 'Y' if the customer wants to rent another
costume else provide any other value: ").upper()
print("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++++++")
else:
print()
print("====================================================")
print(" Bill Details ")
print("====================================================")
print("****************************************************")
print("Name of Customer: ", customer_name)
print()
print("Date and time of rent: ", date_time)
print()
print("Total Price: $", price)
print()
print("Items Rented are: ",", ".join(rented_costumes))
print()
print("Brand of the Items are: ",", ".join(items_brand))
print("****************************************************")
AAROHAN SUBEDI 45
CS4051NI Fundamentals of Computing
print()
print("+++++++++++++++++++++++++++++++++++++++++++++++++")
print("| Rent Details Bill has been generated. |")
print("+++++++++++++++++++++++++++++++++++++++++++++++++")
print()
num=str(random.randint(999999999,9999999999))
bill = open("Rent_"+customer_name+"_"+num+".txt","w")
bill.write("===============================================\n")
bill.write(" Invoice \n")
bill.write("===============================================\n")
bill.write(" Name of Customer: " + str(customer_name))
bill.write("\n Date and time of rent: " +str(date_time))
bill.write("\n Total Price: $" + str(price))
bill.write("\n Items rented are: " + ", ".join(rented_costumes))
bill.write("\n Brand of the Items are: " +", ".join(items_brand))
bill.write("\n===============================================")
bill.close()
loop = False
else:
views.costume_unavailable()
AAROHAN SUBEDI 46
CS4051NI Fundamentals of Computing
Return.py
import datetime
import random
import views
import return_Fun
def return_costume():
views.Return()
return_Fun.catalog()
return_Fun.dictionary_return()
dictionaryCostume = return_Fun.dictionary_return()
returnCostumeID = return_Fun.valid_costume_ID()
rented_costumes = []
items_brand = []
(int(dictionaryCostume[returnCostumeID][3]) > 0)
net = return_Fun.quantity(int(dictionaryCostume[returnCostumeID][3]))
dictionaryCostume[returnCostumeID][3] = int(dictionaryCostume[returnCostumeID][3]) + net
print()
print(dictionaryCostume)
days = int(input("\nHow many days have you rented the costume: "))
total_fine = 0
if days<=5:
fine_days = 0
elif days>5:
fine_days=days-5
total_fine += (fine_days * 10)
print("The total fine is: $", total_fine)
AAROHAN SUBEDI 47
CS4051NI Fundamentals of Computing
rented_costumes.append(dictionaryCostume[returnCostumeID][0])
return_Fun.stock_costume(dictionaryCostume)
items_brand.append(dictionaryCostume[returnCostumeID][1])
return_Fun.stock_costume(dictionaryCostume)
print()
print("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+++++++++++++++")
print("Have the customer rented another costume as well??")
returnMORE = input("Please enter 'Y' if the costume has to be returned else provide any
other value: ").upper()
print("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++")
loop = True
while loop == True:
if returnMORE == "Y":
views.Return()
return_Fun.catalog()
dictionaryCostume = return_Fun.dictionary_return()
returnCostumeID = return_Fun.valid_costume_ID()
int(dictionaryCostume[returnCostumeID][3]) > 0
AAROHAN SUBEDI 48
CS4051NI Fundamentals of Computing
net = return_Fun.quantity(int(dictionaryCostume[returnCostumeID][3]))
dictionaryCostume[returnCostumeID][3] = int(dictionaryCostume[returnCostumeID][3])
+ net
print()
print(dictionaryCostume)
days = int(input("\nHow many days have you rented the costume: "))
if days<=5:
fine_days = 0
elif days>5:
fine_days=days-5
total_fine += (fine_days * 10)
print("The total fine is: $", total_fine)
rented_costumes.append(dictionaryCostume[returnCostumeID][0])
return_Fun.stock_costume(dictionaryCostume)
items_brand.append(dictionaryCostume[returnCostumeID][1])
return_Fun.stock_costume(dictionaryCostume)
print()
print("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+++++++++++++++")
print("Have the customer rented another costume as well??")
returnMORE = input("Please enter 'Y' if the costume has to be returned else provide
any other value: ").upper()
print("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++")
else:
AAROHAN SUBEDI 49
CS4051NI Fundamentals of Computing
print()
print("====================================================")
print(" Bill Details ")
print("====================================================")
print("****************************************************")
print("Name of Customer: ", customer_name)
print()
print("Date and time of Return: ", date_time)
print()
print("Total Fine: $", total_fine)
print()
print("Items Returned are: ", ", ".join(rented_costumes))
print()
print("Brand of the Items are: ",", ".join(items_brand))
print("****************************************************")
print()
print("+++++++++++++++++++++++++++++++++++++++++++++++++++")
print("| Return Details Bill has been generated. |")
print("+++++++++++++++++++++++++++++++++++++++++++++++++++")
print()
num=str(random.randint(999999999,9999999999))
bill = open("Return_"+customer_name+"_"+num+".txt","w")
bill.write("==============================================\n")
bill.write(" Invoice \n")
bill.write("==============================================\n")
bill.write("Name of Customer: " + str(customer_name))
bill.write("\nDate and time of Return: " +str(date_time))
bill.write("\nTotal Fine: $" +str(total_fine))
bill.write("\nItems returned are: " + ", ".join(rented_costumes))
bill.write("\nBrand of the Items are: " +", ".join(items_brand))
AAROHAN SUBEDI 50
CS4051NI Fundamentals of Computing
bill.write("\n==============================================")
bill.close()
loop = False
AAROHAN SUBEDI 51
CS4051NI Fundamentals of Computing
rental_Fun.py
import views
def catalog():
file = open("costumes.txt","r")
print("------------------------------------------------------------------------")
print(" ID\tCustomeName\t\t\tCostumeBrand\tPrice\tQuantity")
print("------------------------------------------------------------------------")
counterID = 0
for line in file:
counterID = counterID + 1
print(" ",counterID, "\t" + line.replace(",","\t"))
file.close()
print("------------------------------------------------------------------------")
def dictionary_rent():
file = open("costumes.txt", "r")
counterID = 0
dictionaryCostume = {}
for line in file:
counterID = counterID + 1
line = line.replace("\n","")
line = line.split(',')
dictionaryCostume[counterID] = line
return dictionaryCostume
def valid_costume_ID():
try:
costumeID = int(input("Enter the ID of costume you want to rent: "))
while costumeID <= 0 or costumeID > len(dictionary_rent()):
views.valid()
AAROHAN SUBEDI 52
CS4051NI Fundamentals of Computing
catalog()
costumeID = int(input("\nEnter the ID of costume you want to rent: "))
return costumeID
except:
views.Invalid_input()
valid_costume_ID()
def quantity(stock):
error = False
while error == False:
try:
net = int(input("Enter the quantity: "))
while net <=0 or net > stock:
if net <= 0:
views.valid_quantity()
else:
views.more_quantity()
net = int(input("Enter the quantity: "))
return net
error = True
except:
views.Invalid()
def stock_costume(dictionary):
file = open("costumes.txt","w")
for i in dictionary.values():
line = str(i[0] + "," + str(i[1]) + "," + str(i[2]) + "," + str(i[3]))
file.write(line)
file.write("\n")
file.close()
AAROHAN SUBEDI 53
CS4051NI Fundamentals of Computing
AAROHAN SUBEDI 54
CS4051NI Fundamentals of Computing
return_Fun.py
import views
def catalog():
file = open("costumes.txt","r")
print("----------------------------------------------------------")
print(" ID\tCustomer Name\tCostume Brand\tPrice\tQuantity")
print("----------------------------------------------------------")
counterID = 0
for line in file:
counterID = counterID + 1
print(" ",counterID, "\t" + line.replace(",","\t"))
file.close()
print("----------------------------------------------------------")
def dictionary_return():
file = open("costumes.txt", "r")
counterID = 0
dictionaryCostume = {}
for line in file:
counterID = counterID + 1
line = line.replace("\n","")
line = line.split(',')
dictionaryCostume[counterID] = line
return dictionaryCostume
def valid_costume_ID():
try:
costumeID = int(input("Enter the ID of costume you want to return: "))
while costumeID <= 0 or costumeID > len(dictionary_return()):
views.valid()
AAROHAN SUBEDI 55
CS4051NI Fundamentals of Computing
catalog()
costumeID = int(input("\nEnter the ID of costume you want to returns: "))
return costumeID
except:
views.Invalid_input()
valid_costume_ID()
def quantity(stock):
error = False
while error == False:
try:
net = int(input("\nEnter the quantity: "))
while net <=0:
if net <= 0:
views.valid_quantity()
net = int(input("Enter the quantity: "))
return net
error = True
except:
views.Invalid()
def stock_costume(dictionary):
file = open("costumes.txt","w")
for i in dictionary.values():
line = str(i[0] + "," + str(i[1]) + "," + str(i[2]) + "," + str(i[3]))
file.write(line)
file.write("\n")
file.close()
AAROHAN SUBEDI 56
CS4051NI Fundamentals of Computing
views.py
def welcome():
print("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++")
print(" -------------------Welcome to Costume Rental Application------------- ")
print("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++")
def options():
print()
print("Select a desirable option to continue :")
print("0. type 0 to Display costumes")
print("1. type 1 to Rent a costume")
print("2. type 2 to Return a costume")
print("3. type 3 to Exit")
print()
def Invalid():
print()
print("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++")
print("!!!!----Invalid input---!!!")
print("Please select the value as per the provided options above.")
print("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++")
print()
def Rent():
print("\n++++++++++++++++++++++++++++++")
print(" ---Let's Rent a Costume--- ")
print("++++++++++++++++++++++++++++++")
AAROHAN SUBEDI 57
CS4051NI Fundamentals of Computing
print()
def invalid_options():
print()
print("+++++++++++++++++++++++++++++++++++++++++++++++++++++++")
print(" !!!Invalid option!!!")
print("Please re-enter the option.")
print("+++++++++++++++++++++++++++++++++++++++++++++++++++++++")
def costume_available():
print("\n++++++++++++++++++++++++++++++")
print(" ! Costume is available ! ")
print("++++++++++++++++++++++++++++++")
print()
def costume_unavailable():
print("\n++++++++++++++++++++++++++++++++")
print(" ! Costume is not available ! ")
print("++++++++++++++++++++++++++++++++++")
print()
def valid():
print("\n++++++++++++++++++++++++++++++++++++++++++++++")
print(" !!!Please provide a valid costume ID!!! ")
print("++++++++++++++++++++++++++++++++++++++++++++++")
print()
def Invalid_input():
print()
print("++++++++++++++++++++++++++++++++++++++++++++++++++++++++")
print(" !!!Invalid input!!! Please re-enter correct value!!! ")
AAROHAN SUBEDI 58
CS4051NI Fundamentals of Computing
print("++++++++++++++++++++++++++++++++++++++++++++++++++++++++")
print()
def valid_quantity():
print("\n++++++++++++++++++++++++++++++++++++++++++")
print(" !!!Please provide a valid quantity!!! ")
print("++++++++++++++++++++++++++++++++++++++++++++")
print()
def more_quantity():
print("\n+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
")
print(" ---Quantity provided is greater than what we have in stock--- ")
print("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++")
print()
def Return():
print("\n++++++++++++++++++++++++++++++++")
print(" ! Let's Return a Costume ! ")
print("++++++++++++++++++++++++++++++++")
print()
def Exit():
print("\n -----Thank you for using our application.-----")
print()
AAROHAN SUBEDI 59
CS4051NI Fundamentals of Computing
BIBILOGRAPHY
AAROHAN SUBEDI 60
CS4051NI Fundamentals of Computing
Originality Report
AAROHAN SUBEDI 61