Download as pdf or txt
Download as pdf or txt
You are on page 1of 61

CS4051NI Fundamentals of Computing

Module Code & Module Title


CS4051NI Fundamentals of Computing

Assessment Weightage & Type


60% Individual Coursework

Year and Semester


2021-22 Summer

Student Name: Aarohan Subedi


Group: C13
London Met ID: 22015633
College ID: Np01cp4s220149
Assignment Due Date:
Assignment Submission Date:

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

Figure 1 Flowchart of costume rental app ....................................................................... 9


Figure 2 Example of int. ................................................................................................ 23
Figure 3 example of float datatype used ....................................................................... 24
Figure 4 use of Boolean ................................................................................................ 24
Figure 5 Use of string datatype ..................................................................................... 24
Figure 6 Giving invalid input and displaying message................................................... 26
Figure 7 testing of negative value as input to rent......................................................... 27
Figure 8 testing non existing value as input for rent ...................................................... 27
Figure 9 First process of renting of costumes ............................................................... 28
Figure 10 Second screenshot of renting another costume ............................................ 29
Figure 11 Generated bill after renting two costumes. .................................................... 29
Figure 12 File generated after the process of renting.................................................... 30
Figure 13 Testing / running return process.................................................................... 31
Figure 14 Quantity deduced while renting costume....................................................... 32
Figure 15 Quantity added when renting custome .......................................................... 32
Figure 16 Originality test ............................................................................................... 52

AAROHAN SUBEDI 4
CS4051NI Fundamentals of Computing

LIST OF TABLES

Table 1 Execution of try-catch method.......................................................................... 25


Table 2 Test for return and borrow................................................................................ 26
Table 3 To test generation of text file of borrow ............................................................ 28
Table 4 Test to check text file generation of return........................................................ 30
Table 5 to check the object in stock .............................................................................. 32

AAROHAN SUBEDI 5
CS4051NI Fundamentals of Computing

1 INTRODUCTION

1.1 Detail of the project

Python is an open-source programming language used in web programming, data


science, artificial intelligence, and many scientific applications (techterm, 2022).

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.

1.2 Goals And Objectives.


The Important Goals and Objective of project are

∙ To display detailed information about the costumes available in the app. ∙


To rent the available costume in the app.
∙ To return the custom in the app.
∙ To exit the 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. Discussion And Analysis

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:

1. Print welcome screen .

2. Print menu as below.

Type 0 to display costumes.

Type 1 to rent a costume.

Type 2 to return a costume.

Type 3 to exit.

3. Input 0-3 from the customer to choose an option in the menu

4. que 0:

a) the input number is 0 to display costumes.

b) Open “costumes.txt” .

c) Read from “costumes.txt” and store the action in a variable “lines”


. d) Print “lines”.
5. que 1:

a) The input number is 1 chosen to rent costumes by customer.

AAROHAN SUBEDI 8
CS4051NI Fundamentals of Computing

b) Input the quantity of the customs.

c) Update the whole data of dictionary.

d) Input the name of the customer.

e) Print the price of the custom.

f) Create a Rent_name_...numbers...txt file with the customer name, costume


rent, cost and stock quantity

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:

h) If yes then rent another costumes.

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

a) The input number chosen is 3 to return the costumes rent by the


customer. b) Enter the id of costume you want to return.
c) Enter the quantity.

d) Update the data of dictionary.

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

h) Add total fine and cost of the costumes

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

a) The input number chosen is 4 to end the program .

b) Print “thank you for using our costume rental Application”


c) End program.

AAROHAN SUBEDI 10
CS4051NI Fundamentals of Computing

2.2 Flowchart

Figure 1 Flowchart of costume rental app

AAROHAN SUBEDI 11
CS4051NI Fundamentals of Computing

2.3 Pseudocode

Pseudocode for rent.py

IMPORT DateTime

IMPORT random

IMPORT views

IMPORT rental_Fun

define rent_costume()

CALL views.Rent()

CALL rental_Fun.catalog()

CALL rental_Fun.dictionary_rent()

SET dictionaryCostume = rental_Fun.dictionary_rent() SET


rentCostumeID = rental_Fun.valid_costume_ID() SET
rented_costumes = [ ]
SET items_brand = [ ]

IF

INPUT > 0

CALL views.costume_available()

INPUT Quantity

INPUT Customer_name

INITALIZE Date_Time

AAROHAN SUBEDI 12
CS4051NI Fundamentals of Computing

STORES rented_costume in dictionary

CALL stock_costume from rental_Fun

STORES item_brand in dictionary


CALL stock_costume from rental_Fun

PRINT “+++++++++++++++++++++++++++++++++++++++++++++” PRINT “Does


the customer want to rent another costume as well?” DECLARE rentMORE = input
PRINT “+++++++++++++++++++++++++++++++++++++++++++++”

while loop is true

IF rent_more is true

CALL views.Rent()

CALL rental_Fun.catalog()

SET dictionaryCostume as rental_Fun.dictionary_rent() SET rentcostumeID as


rental_Fun.valid_costume_ID()
IF input >0

CALL views.costume_available()

Ask quantity

If input meets, stock_quantity - input_quantity PRINT dictionaryCostume

ADD rented costume in rented_costume CALL


rental_Fun.stock_costume(dictionaryCostume)
ADD rented costume brand in items_brand CALL

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 “Does the customer want to rent another costume as well?”

DECLARE rentMORE = input

PRINT
“+++++++++++++++++++++++++++++++++++++++++++++”

END IF

ELSE

PRINT “===============================================” PRINT “ Bill


Details ” PRINT “===============================================”
PRINT “******************************************************************” PRINT “Name of
Customer: + customer_name”
BREAK

PRINT “Date and time of rent: + date_time”

BREAK

PRINT “Total Price: $ + price”

PRINT “Items Rented are: JOIN rented_costume”

PRINT “Brand of the Items are: JOIN items_brand ” BREAK


PRINT “*****************************************************” BREAK
PRINT “++++++++++++++++++++++++++++++++++++++++++++++++” PRINT “|

AAROHAN SUBEDI 14
CS4051NI Fundamentals of Computing

Rent Details Bill has been generated. |”


PRINT “++++++++++++++++++++++++++++++++++++++++++++++++”

SET num is random number upto 9999999999

SET bill = “Rent + customer_name + num + “.txt” + “write”

DEFINE bill.write

PRINT “==============================================” PRINT “


Invoice ” PRINT “==============================================”
PRINT “Name of Customer:” + String(customer_name) BREAK
PRINT “Date and time of rent :” + String(date_time) BREAK
PRINT “Total Price: $” + String(price)

BREAK

PRINT “Items rented are:” JOIN (rented_ costumes) BREAK


PRINT “Brand of the Items are:” JOIN (items_brand) PRINT
“==============================================” CLOSE bill.write()

While loop is false

END ELSE

ELSE

CALL views.costume_unavailable()

END ELSE

Pseudocode for views.py

AAROHAN SUBEDI 15
CS4051NI Fundamentals of Computing

DEFINE welcome()

PRINT “++++++++++++++++++++++++++++++++++++++++++++”
PRINT “ Welcome to Costume Rental Application” PRINT
“+++++++++++++++++++++++++++++++++++++++++++++”

DEFINE options()

PRINT “Select a desirable option”

PRINT “(0) || press 0 to Display costumes”

PRINT “(1) || Press 1 to Rent a costume”

PRINT “(2) || Press 2 to Return a costume”

PRINT “(3) || Press 3 to Exit”

DEFINE Invalid()

PRINT “Invalid input!!!”

PRINT “Please select the value as per the provided options.”

DEFINE Rent()

PRINT “++++++++++++++++++++++++++++++”

PRINT “ Let's Rent a Costume ”

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 “ Costume is available ”

PRINT “++++++++++++++++++++++++++++++”

DEFINE costume_unavailable()

PRINT “++++++++++++++++++++++++++++++++”

PRINT “ Costume is not available ”

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 “ Let's Return a Costume ”

PRINT “++++++++++++++++++++++++++++++++”

DEFINE Exit()

PRINT “ Thank you for using our application. ”

Pseudocode for main.py

IMPORT Rent

IMPORT Return

IMPORT views

CALL views.welcome()

while(True):

function views.option()

TRY:

INPUT “select a choice from 1 - 4 : “ in integer datatype in variable “choose”

Continue if option is true

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

Pseudocode for Rent.py

IMPORT DateTime

IMPORT random

IMPORT views

IMPORT rental_Fun

def rent_costume():

CALL views.Rent()

CALL rental_Fun.catalog() CALL


rental_Fun.dictionary_rent()
SET dictionaryCostume = rental_Fun.dictionary_rent() SET
rentCostumeID = rental_Fun.valid_costume_ID() SET
rented_costumes = [ ]
SET items_brand = [ ]

IF

Input > 0

CALL views.costume_available() ASK


Quantity
ASK Customer_name

AAROHAN SUBEDI 20
CS4051NI Fundamentals of Computing

Pseudocode for return.py

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 = [ ]

ASK costume_id to return

If input is true

ASK quantity

BREAK

PRINT dictionarycostume
ASK rented time

PRINT “ How many days have you rented the costume:”

If input > 5

AAROHAN SUBEDI 21
CS4051NI Fundamentals of Computing

SET fine = input * 10

END IF

ELSE

SET fine = 0

PRINT “The total fine is: $” + fine

SET costomer_name = ask PRINT “Enter the name of customer:”


SET date_time = current date and time

ADD rented_costumes in dictionarycostume

CALL return_Fun.stock_costume(dictionarycostume)

ADD items_brands in 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 = [ ]

ASK costume_id to return

If input is true

ASK quantity

BREAK

PRINT dictionarycostume

ASK rented time

PRINT “ How many days have you rented the


costume:” END IF

If input > 5

SET fine = input * 10

END IF

ELSE

SET fine = 0

PRINT “The total fine is: $” + fine

SET costomer_name = ask PRINT “Enter the name of customer:”

AAROHAN SUBEDI 23
CS4051NI Fundamentals of Computing

SET date_time = current date and time

ADD rented_costumes in dictionarycostume

CALL returnFunc.stock_costume(dictionarycostume)

ADD items_brands in 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

PRINT “ Date and time of Return:” + date_time

AAROHAN SUBEDI 24
CS4051NI Fundamentals of Computing

BREAK

PRINT “Total Fine: $” + total_fine

BREAK

PRINT “Items Returned are:” JOIN rented_costumes

BREAK

PRINT “Brand of the Items are:” JOIN items_brand


PRINT “****************************************************”

BREAK

PRINT
“+++++++++++++++++++++++++++++++++++++++++++++++++++”
PRINT “| Return Details Bill has been generated. |”
PRINT
“+++++++++++++++++++++++++++++++++++++++++++++++++++”
BREAK

SET num is random number upto 9999999999

CALL bill.write()

bill = OPEN bill.write “Return” + costumer_name + num + “.txt”, “write”


PRINT “==============================================”
PRINT “ Invoice ”
PRINT
“==============================================” PRINT
“Name of Customer:” + String(customer_name)
BREAK

PRINT “Date and time of rent :” + String(date_time)

BREAK

AAROHAN SUBEDI 25
CS4051NI Fundamentals of Computing

PRINT “Total Price: $” + String(price)

BREAK

PRINT “Items rented are:” JOIN (rented_ costumes)

BREAK

PRINT “Brand of the Items are:” JOIN (items_brand)

PRINT “==============================================”
CLOSE bill.write()
While loop is false

END ELSE

AAROHAN SUBEDI 26
CS4051NI Fundamentals of Computing

2.4 Data Structures.


Data structures are the fundamental constructs around which you build your programs.
Each data structure provides a particular way of organizing data so it can be accessed
efficiently, depending on your use case. Python ships with an extensive set of data
structures in its standard library (python, 2022)

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.

Use of list (Non-primitive data structure)

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.

Primitive data structure

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.

Figure 2 Example of int.

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.

Figure 3 example of float datatype used

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.

Figure 4 use of Boolean

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.

Figure 5 Use of string datatype

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.

Python documents used on this application are main.py, Rent.py, Return.py,


rentFunc.py, returnFunc.py, view.py and costumes.txt.

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

Objective To check whether the implementation


of the try-catch method is valid or not.

Action Provide string input

Expected Result It should be able to handle any invalid


input and display a “please enter a
valid choice from 0-3” message

Actual Result It handled the exception and showed


a “please enter a valid choice from
0-3” message

Conclusion The test was successful

Table 1 Execution of try-catch method

Figure 6 Giving invalid input and displaying message

AAROHAN SUBEDI 30
CS4051NI Fundamentals of Computing

TEST 2

Objective Testing selection of rent and return option

Action Provide a negative value as input and


provide the random non-existent value
as input.

Expected results Negative value and non-existence


values show an error message.

Actual results Negative value and non-existence


values show an error message.

Conclusion Test was successful.

Table 2 Test for return and borrow

Figure 7 testing of negative value as input to rent

AAROHAN SUBEDI 31
CS4051NI Fundamentals of Computing

Figure 8 testing non existing value as input for rent

TEST 3

Objective To check text file generation of


rent multiple costumes.

Action Run the rent process and check


the generated text file.

Expected Result Borrow file of the borrower is generated.

Actual Results Borrow file of the borrower is generated

Conclusion Test was successful

AAROHAN SUBEDI 32
CS4051NI Fundamentals of Computing

Table 3 To test generation of text file of borrow

Figure 9 First process of renting of costumes

AAROHAN SUBEDI 33
CS4051NI Fundamentals of Computing

Figure 10 Second screenshot of renting another costume

AAROHAN SUBEDI 34
CS4051NI Fundamentals of Computing

Figure 11 Generated bill after renting two costumes.

Figure 12 File generated after the process of renting

3.2 File
TEST 4

AAROHAN SUBEDI 35
CS4051NI Fundamentals of Computing

Objective To check text file generation of return


of costumes.

Action Run the returning process and check


the generated text file and also show
output in shell.

Expected Results Return file should be generated.

Actual Results Return file should be generated.

Conclusion The test was successful

Table 4 Test to check text file generation of return

AAROHAN SUBEDI 36
CS4051NI Fundamentals of Computing

Figure 13 Testing running return process

Figure 14: Another screenshot of returning process

AAROHAN SUBEDI 37
CS4051NI Fundamentals of Computing

3.3 Txt file


TEST 5

Objective To check whether the costumes


stocks will be updated by the
program or not.

Action Show quantity being deducted


while renting costume
Show the quantity being added
while returning costume.

Expected results Quantity decreases after borrowing


and increases after returning

Actual results Quantity decreases after borrowing


and increases after returning

Conclusion The test was successful

Table 5 to check the object in stock

AAROHAN SUBEDI 38
CS4051NI Fundamentals of Computing

Figure 15: .txt file of rent process

Figure16: .txt file of returning process

Figure 17: quantity added after returning process.

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)

customer_name = input("\nEnter the name of customer: ")

date_time = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")

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)

price = rental_Fun.Total_price(dictionaryCostume,net,rentCostumeID) + price

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

customer_name = input("\nEnter the name of customer: ")

date_time = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")

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

def Total_price(dictionary, quantityDetails, rentCostumeID):


price = float(dictionary[rentCostumeID][2].replace("$",""))
print("\nThe price of costume:", price)
pricePerItem = price * quantityDetails
return pricePerItem

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

python, r. (2022). Retrieved from https://realpython.com/python-data


structures/#:~:text=Data%20structures%20are%20the%20fundamental,structur
e s%20in%20its%20standard%20library.

techterm. (2022). techterms. Retrieved from https://techterms.com/definition/python

tuitorialpoint. (2022). Retrieved from


https://www.tutorialspoint.com/python_data_structure/python_algorithm_design.
h
tm#:~:text=Algorithm%20is%20a%20step%2Dby,more%20than%20one%20pro
g ramming%20language.

AAROHAN SUBEDI 60
CS4051NI Fundamentals of Computing

Originality Report

Figure 18 Originality test

AAROHAN SUBEDI 61

You might also like