FOC DOCUMENTATION Sem - 2 NEwwwww
FOC DOCUMENTATION Sem - 2 NEwwwww
I confirm that I understand my coursework needs to be submitted online via MySecondTeacher 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 mark of zero will be awarded.
Table of Contents
1. Introduction ............................................................................................................... 1
Goal ............................................................................................................................. 2
Objectives .................................................................................................................... 3
Algorithm ..................................................................................................................... 4
Flowchart......................................................................................................................... 7
4. Pseudocode ............................................................................................................ 10
6. Program .................................................................................................................. 30
7. Testing .................................................................................................................... 38
Test 1......................................................................................................................... 38
Test 2:........................................................................................................................ 39
Test 3......................................................................................................................... 41
Test 4......................................................................................................................... 44
Test 5......................................................................................................................... 45
8. Conclusion .............................................................................................................. 50
9. Appendix ................................................................................................................. 51
11. Report.................................................................................................................. 70
List of Figures
Figure 1 : Logo of Python Programming Language ......................................................... 1
Figure 2 : Basic Flowchart ............................................................................................... 7
Figure 3 : Flowchart of my Program ................................................................................ 9
Figure 4 : In my program, integer is used. ..................................................................... 24
Figure 5 : Float also used in my program. ..................................................................... 25
Figure 6 : In my program Boolean is used..................................................................... 26
Figure 7 : In my program List is used. ........................................................................... 27
Figure 8 : Example of Tuple. ......................................................................................... 28
Figure 9 : Example of Set. ............................................................................................. 28
Figure 10 : Example of Dictionary. ................................................................................ 29
Figure 11 : Modules of my Program. ............................................................................. 30
Figure 12 : Complete process of Add Quantity. ............................................................. 33
Figure 13 : Complete process of Selling Laptops. ......................................................... 34
Figure 14 : Complete process of making txt file. ........................................................... 36
Figure 15 : Generate Text file after selling laptop. ......................................................... 36
Figure 16 : Exit part of my program. .............................................................................. 37
Figure 17 : Giving String input where inputs integer value. ........................................... 38
Figure 18 : Provide negative value in quantity. .............................................................. 39
Figure 19 : Provide none existed value in quantity. ....................................................... 40
Figure 20 : Step 1st before selling the laptop. ............................................................... 41
Figure 21 : Show selling output in shell. ........................................................................ 42
Figure 22 : Show the renting in txt file. .......................................................................... 43
Figure 23 : Display option before display laptop. ........................................................... 44
Figure 24 : Exit the program and display again the choosing option. ............................ 45
Figure 25 : Selling the laptop. ........................................................................................ 46
Figure 26 : Successfully deduct quantity. ...................................................................... 46
Figure 27 : Showing bill on txt file after selling. ............................................................. 47
Figure 28 : Before add quantity of laptops..................................................................... 48
Figure 29 : Before add quantity of laptop. ..................................................................... 48
Figure 30 : Displaying the txt file after add quantity of laptop. ....................................... 49
Figure 31 : Displaying after adding quantity of XPS. ..................................................... 49
List of Tables
Table 1 : Table for Test 1 .............................................................................................. 38
Table 2 : Table for Test 2 for providing negative value.................................................. 39
Table 3 : Table for Test 2 for providing none existed value. .......................................... 40
Table 4 : Table for Test 3 for showing complete renting process. ................................. 41
Table 5 : Table for Test 4 .............................................................................................. 44
Table 6 : Table for Test 5. ............................................................................................. 45
Table 7 : Table for Test 5.1 ........................................................................................... 47
CS4051NT Fundamentals of Computing
1. Introduction
Python is a powerful, versatile, and widely used programming language. Web
development, machine learning applications, and other advanced industry technology
all employ the Python programming language (latest version is Python 3). Google,
Amazon, Facebook, Instagram, Dropbox, Uber, and many more big tech companies use
the Python programming language.
The largest advantage of Python is very large standard library, which may be utilized for
the following things:
• Machine Learning
• GUI applications, such as PyQt, Kivy, and Tkinter, etc.
• Web frameworks such as Django (used by Dropbox, Instagram, and YouTube)
• Scientific computing
Python is now the most popular high-level, multipurpose programming language that
supports procedural and object-oriented programming. In general, Python applications
are smaller than those written in other languages like Java. As a result of the language's
indentation requirement, programmers must type comparatively less, and their work is
always readable. (Anderson, 2023)
1
Arpan Karki 22072096
CS4051NT Fundamentals of Computing
2
Arpan Karki 22072096
CS4051NT Fundamentals of Computing
name and brand, the date and time of the transaction, the net amount (without VAT), the
VAT amount (13% of the total price), and the gross amount (including VAT). The text file
must readily allow the software application to update the information about the laptops,
including the name, brand, price, number available, CPU specifications, and graphic card
specifications.
Objectives
The main objective of this project is to create user-friendly software for a laptop store. It
will help manage the process of buying laptops from producers and selling them to
customers, whether they are individuals or businesses. The software will use a text file to
keep track of the laptops available in the store. It can read and update this file, so the
information is always up to date. With the software, store employees can easily see which
laptops are available, and the stock count will automatically adjust after each sale or
purchase.
The software will also generate notes or receipts for every transaction. These documents
will include important details like customer information, laptop model, price, and any
additional notes. By using this software, the laptop store can improve its operations, keep
better track of inventory, and provide a smoother purchasing experience for customers
and employees.
3
Arpan Karki 22072096
CS4051NT Fundamentals of Computing
Algorithm of my program
Step 1: Start
If choice is 1, go to Step 4
If choice is 2, go to Step 6
If choice is 3, go to Step 13
If choice is 4, go to Step 21
4
Arpan Karki 22072096
CS4051NT Fundamentals of Computing
If no, go to Step 3
If yes, go to Step 11, Step 20, Display: "Laptop Name successfully Added
to Stock.", go to Step 3
If no, go to Step 3
5
Arpan Karki 22072096
CS4051NT Fundamentals of Computing
Step 20: Create a unique note for adding laptop as a .txt file.
6
Arpan Karki 22072096
CS4051NT Fundamentals of Computing
Flowchart
A flowchart is a diagram that shows how a system, computer algorithm, or process works.
They are frequently used in many different disciplines to examine, organize, enhance,
and convey frequently complicated processes in simple, understandable diagrams.
Rectangles, ovals, diamonds, and perhaps many more shapes are used in flowcharts,
also known as flow charts, to indicate the kind of step and connecting arrows to indicate
flow and sequence. They can be anything from straightforward hand-drawn charts to
detailed computer-drawn diagrams showing numerous steps and routes. Considering all
the different variations, flowcharts are among the most widely used diagrams on the
world, being utilized by both technical and non-technical persons in a wide range of
industries. Process Flowchart, Process Map, Functional Flowchart, Business Process
Mapping, Business Process Modeling and Notation (BPMN), or Process Flow Diagram
(PFD) are some of the more technical names for flowcharts. They have a connection with
other well-known diagrams like Data Flow Diagrams (DFDs) and UML Activity Diagrams.
(Peterson, 2022)
7
Arpan Karki 22072096
CS4051NT Fundamentals of Computing
1. Document a process.
By creating a flowchart, individuals can map out the steps, sequences, and decisions
involved in the project or process, and gain a better understanding of how it works.
Overall, flowcharts can be a valuable tool for enhancing collaboration and improving
project outcomes.
Sometimes team members may not have the resources or time to read through a
lengthy and complex process document. To ensure that everyone understands the
workflow, a flowchart can be created that shows the tasks and individual steps in a
simple and easy-to-follow manner. This makes it possible for team members to
analyze the process and gain a clear understanding of it quickly and easily.
Making decisions might seem less difficult and complex when they are expressed
graphically in a flowchart. A flowchart can also make it easier to comprehend the
probable results of a choice, which makes it easier to forecast and justify ensuing
actions.
Using flowcharts can help you spot possible problems or impediments in a process
early on. It is simpler to follow each phase and make sure that each activity is given
enough time and resources when the entire process is shown. This enables you to
take proactive measures to resolve any bottlenecks or inefficiencies before they
worsen.
8
Arpan Karki 22072096
CS4051NT Fundamentals of Computing
Flowchart of my Program
9
Arpan Karki 22072096
CS4051NT Fundamentals of Computing
4. Pseudocode
Pseudocode is a description of an algorithm or computer program written in plain English
that provides an informal, high-level representation of the actual code. Pseudocode is a
useful tool for programmers because it allows them to express their ideas and concepts
without worrying about the syntax of a specific programming language. By using plain
English, programmers can easily communicate their thoughts, even if they work on
different languages. Pseudocode is also easy to read and write, making it a convenient
way to quickly capture and share ideas. The use of pseudocode is a methodology that
helps programmers to present the implementation of an algorithm. Pseudocode provides
a simplified representation of code that can be easily understood by programmers,
regardless of their programming background or knowledge. It is essentially a mock-up or
a rough sketch of code that can be quickly understood by anyone with basic programming
knowledge. This is why algorithms are often represented in pseudocode, as it provides a
straightforward and easy-to-understand way to communicate complex ideas.
(theprogrammedwords, 2023)
Advantages of Pseudocode
▪ Enhances the readability of any strategy. It's one of the most effective ways to
begin implementing an algorithm.
▪ Acts as a connector between the algorithm or flowchart and the program.
Serves as a rudimentary documentation tool and, when put down in
pseudocode, enables understanding of a developer's product.
▪ Pseudocode's primary objective is to precisely describe what each line of a
program should accomplish, making programming easier for the programmer.
▪ Before creating actual code, a program can be planned out in pseudocode,
which helps to structure and organize the development process.
10
Arpan Karki 22072096
CS4051NT Fundamentals of Computing
TRY
flag = True
WHILE flag
PRINT"______________________________________________"
PRINT"______________________________________________"
IF selectOption is a digit
displayLaptop(readLaptopList())
PRINT "______________________"
PRINT "______________________"
Sell.sellLaptops(readLaptopList())
11
Arpan Karki 22072096
CS4051NT Fundamentals of Computing
PRINT "__________________________"
PRINT "__________________________"
ELSE
END IF
displayLaptop(readLaptopList())
PRINT"__________________________________________"
Sell.sellLaptops(readLaptopList())
displayLaptop(readLaptopList())
PRINT "____________________________________________"
Add.addLaptopStock(readLaptopList())
flag = False
PRINT "__________________________"
12
Arpan Karki 22072096
CS4051NT Fundamentals of Computing
PRINT "__________________________"
ELSE
END IF
ELSE
END IF
END WHILE
EXCEPT ValueError as e
PRINT e
END TRY
selectOptions()
END FUNCTION
13
Arpan Karki 22072096
CS4051NT Fundamentals of Computing
FUNCTION readLaptopList()
laptopsList = []
lines = file.READLINES()
a = SPLIT(STRIP(line), ",")
laptopsList.APPEND(a)
file.CLOSE()
RETURN laptopsList
END FUNCTION
FUNCTION displayLaptop(laptopsList)
laptop = laptopsList[i]
laptop.INSERT(0, i + 1)
headers = [
"S.No.",
"Name",
"Company",
"Price",
14
Arpan Karki 22072096
CS4051NT Fundamentals of Computing
"Quantity",
"Generation",
"Graphics Card",
table = COPY(laptopsList)
table.INSERT(0, headers)
END FUNCTION
15
Arpan Karki 22072096
CS4051NT Fundamentals of Computing
FUNCTION sellLaptops(laptopsList)
TRY
PRINT "__________________________________________"
RETURN
laptop = laptopsList[i]
IF i + 1 equals number
RETURN
RETURN
16
Arpan Karki 22072096
CS4051NT Fundamentals of Computing
updateStock(laptopsList)
PRINT "Congratulations! The " + laptop[1] + " laptop is now in the hands of " +
name + "."
RETURN
PRINT "__________________________________________________"
PRINT "We apologize, but the laptop you are seeking is not currently available."
EXCEPT ValueError
PRINT "Integer Value should be entered for Laptops numbers and Quantity"
END TRY
END FUNCTION
FUNCTION updateStock(laptopsList)
FOR j in range(6)
IF j equals 5
update.WRITE(str(laptopsList[i][j]) + "\n")
17
Arpan Karki 22072096
CS4051NT Fundamentals of Computing
ELSE
update.WRITE(str(laptopsList[i][j]) + ",")
CLOSE update
END FUNCTION
selected_laptop = laptopsList[userNumber-1]
Name = selected_laptop[0]
company = selected_laptop[1]
price = selected_laptop[2]
gen = selected_laptop[4]
graphicsCard = selected_laptop[5]
f.WRITE("______________________________________________________\n")
18
Arpan Karki 22072096
CS4051NT Fundamentals of Computing
f.WRITE(" ________________________\n")
f.WRITE("_____________________________________________________\n")
f.WRITE("Name: {}\n".FORMAT(Name))
f.WRITE("Company: {}\n".FORMAT(company))
f.WRITE("Quantity: {}\n".FORMAT(quantity))
f.WRITE("Price: {}\n".FORMAT(price))
f.WRITE("Generation: {}\n".FORMAT(gen))
f.WRITE("___________________________\n")
f.WRITE("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\n")
f.WRITE("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \n")
PRINT "_____________________________________________________"
PRINT "______________________________________"
19
Arpan Karki 22072096
CS4051NT Fundamentals of Computing
f.CLOSE()
ELSE
f.WRITE("_____________________________________________________\n")
f.WRITE("______________________________________________________ \n")
f.WRITE("Name: {}\n".FORMAT(Name))
f.WRITE("Company: {}\n".FORMAT(company))
f.WRITE("Quantity: {}\n".FORMAT(quantity))
f.WRITE("Price: {}\n".FORMAT(price))
f.WRITE("Generation: {}\n".FORMAT(gen))
f.WRITE("____________________\n")
f.WRITE("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - “)
print("_____________________________________________________")
20
Arpan Karki 22072096
CS4051NT Fundamentals of Computing
print("______________________________________")
f.close()
FUNCTION addLaptopStock(laptopList)
PRINT "__________________________________________"
RETURN
IF (i + 1) equals laptopNumber
a = CAST(laptopList[i][3] to INTEGER)
a += laptopStock
laptopList[i][3] = a
Sell.updateStock(laptopList)
21
Arpan Karki 22072096
CS4051NT Fundamentals of Computing
PRINT "_______________________________________"
PRINT "Display the list of laptops to see the newly added quantity"
PRINT"_________________________________________________________"
END FOR
END FUNCTION
IF (i + 1) equals laptopNumber
Name = laptopList[i][0]
company = laptopList[i][1]
price = laptopList[i][2]
quantity = laptopList[i][3]
gen = laptopList[i][4]
graphicsCard = laptopList[i][5]
f.WRITE("\n" + "\t\t_______________________________________")
22
Arpan Karki 22072096
CS4051NT Fundamentals of Computing
f.WRITE("\n""\t\t_____________________________________________")
f.WRITE("\n" + "\t\t________________________________________")
f.WRITE("\n""\t\t_______________________________________")
f.CLOSE
END FUNCTION
23
Arpan Karki 22072096
CS4051NT Fundamentals of Computing
5. Data Structures
A storage that is used to store and arrange data is called a data structure. It is a method
of setting up data on a computer to make it easily accessible and up to date. A data
structure is used for more than just data organization. Additionally, it is employed for data
processing, retrieval, and archiving. Nearly all existing software systems and programs
make use of a variety of simple and sophisticated data structure types. Therefore, we
need to be well-versed in data structures. (Preston, 2023)
Data structures may be divided into two groups: both primitive and nonprimitive data
types. These are described below.
i. Integer
24
Arpan Karki 22072096
CS4051NT Fundamentals of Computing
ii. Float
iii. Boolean
A result that can only be true or false is referred to as a boolean result. Boolean
logic creates a value that can be either true or false by combining two
statements or expressions with a logical operator.
25
Arpan Karki 22072096
CS4051NT Fundamentals of Computing
26
Arpan Karki 22072096
CS4051NT Fundamentals of Computing
i. List
In my program, I utilized a list as well. The reason behind this choice is that a
list allows me to store various data types, granting flexibility in handling
different kinds of information. Moreover, by using index numbers, I can easily
retrieve any specific data from the list. Another advantage of using a list is its
mutability, enabling me to modify or substitute values as needed. Given that
my program primarily focuses on updating values, the utilization of a list
proves to be highly beneficial.
27
Arpan Karki 22072096
CS4051NT Fundamentals of Computing
ii. Tuple
iii. Set
A set is a collection of items that does not have a specific order and only
contains unique elements. This implies that duplicate elements are not
allowed in a set. Therefore, a set is a useful data structure to store unique
items and perform operations such as intersection, union, and difference
between sets.
28
Arpan Karki 22072096
CS4051NT Fundamentals of Computing
iv. Dictionary
29
Arpan Karki 22072096
CS4051NT Fundamentals of Computing
6. Program
i. Main.py
This module is the main part of my program and it starts the program. It uses three other
modules called Sell.py, Read.py, and Add.py to do different tasks. There is a function in
this module called selectOptions() which shows the user four options and asks them to
select number of your choice: If the user selects option 1, they can see the details of
available laptops. Option 2 allows the user to sell a laptop to a customer. Option 3 lets
the user add laptops to the stock, and option 4 is used to exit the program.
ii. Sell
This module includes the sellLaptops() function that prompts the user to input the
customer's name, the laptop number, and the quantity to be purchased. Then checks if
the entered laptop number is available in the stock. If it is available, the selected laptop's
quantity in the stock is reduced by the amount purchased by the customer. An invoice is
generated in the customer's name, containing all the laptop details, and a message
indicating that the purchase was successful is displayed.
30
Arpan Karki 22072096
CS4051NT Fundamentals of Computing
iii. Read
The code imports the tabulate module which is used to create tables in the console from
a list. The function readLaptopList() reads the data from a file named "laptops.txt" and
returns a list of laptops. The file should have the laptop details in a specific format: each
line should contain the details of one laptop separated by a comma and a space. The
order of details should be: name, company, price, quantity, generation, graphics card.
The function opens the file in read mode, reads all the lines, strips the whitespace
characters and splits the line using the comma and space separator. Then, it appends
the details of the laptop as a list to the laptopsList list. Finally, it returns the laptopsList
list.
iv. Add
This code defines two functions: addLaptopStock() and addLaptopStockDetails(). The
addLaptopStock() function prompts the user to enter the number and quantity of laptops
to be added to the stock, along with the shipping company and cost. It then updates the
quantity of the specified laptop in the stock and calls the addLaptopStockDetails() function
to create a text file with the details of the added laptops, including the shipping
information. The function Sell.updateStock() is also called to update the stock details in
the Laptops.txt file. The addLaptopStockDetails() function creates a text file with the
details of the added laptop, including its name, company, price, quantity, generation,
graphics card, and shipping details. To obtain the current date and time for the delivery
date and time in the file, it makes use of the datetime module.
31
Arpan Karki 22072096
CS4051NT Fundamentals of Computing
v. Invoice
This module imports two built-in modules, datetime and os. It defines a parameterized
function named invoice() that is called from the sellLaptops() function of the sellLaptops
module. The invoice() function checks if the laptop number entered by the user exists in
the stock. If it does, the function generates an invoice with the customer's name, purchase
date, and other laptop details. It also checks if an invoice file with the given customer
name exists in the directory. If it does not exist, it creates a new text file with the customer
name. If it exists, it appends the laptop details to the previous text file.
32
Arpan Karki 22072096
CS4051NT Fundamentals of Computing
33
Arpan Karki 22072096
CS4051NT Fundamentals of Computing
34
Arpan Karki 22072096
CS4051NT Fundamentals of Computing
35
Arpan Karki 22072096
CS4051NT Fundamentals of Computing
36
Arpan Karki 22072096
CS4051NT Fundamentals of Computing
37
Arpan Karki 22072096
CS4051NT Fundamentals of Computing
7. Testing
Test 1
Objective To check the implementation of try except
Action String input was given in the choice which
inputs integer value
Excepted Result It should display the valueError message
Actual Result It displayed the valueError message
Conclusion Test successful.
38
Arpan Karki 22072096
CS4051NT Fundamentals of Computing
Test 2:
Provide negative value as input.
39
Arpan Karki 22072096
CS4051NT Fundamentals of Computing
40
Arpan Karki 22072096
CS4051NT Fundamentals of Computing
Test 3
Show complete selling process.
41
Arpan Karki 22072096
CS4051NT Fundamentals of Computing
42
Arpan Karki 22072096
CS4051NT Fundamentals of Computing
43
Arpan Karki 22072096
CS4051NT Fundamentals of Computing
Test 4
Objective Following every operation, to find out if
the program is in a loop or not.
Action The program is used to purchase a
laptop.
Excepted Result It should display the choosing options
again.
Actual Result It displayed the choosing options again.
Conclusion Test successful.
44
Arpan Karki 22072096
CS4051NT Fundamentals of Computing
Figure 24 : Exit the program and display again the choosing option.
Test 5
Showing the quantity being deduct while selling.
45
Arpan Karki 22072096
CS4051NT Fundamentals of Computing
46
Arpan Karki 22072096
CS4051NT Fundamentals of Computing
47
Arpan Karki 22072096
CS4051NT Fundamentals of Computing
48
Arpan Karki 22072096
CS4051NT Fundamentals of Computing
49
Arpan Karki 22072096
CS4051NT Fundamentals of Computing
8. Conclusion
The first coursework in the Fundamental of Computing module was quite challenging. We
had to create a Python program for a laptop rental shop. The program needed to read
and update information stored in a text file. It was tough, but with hard work and
commitment, I managed to complete the task.
To make the program work smoothly, I had to use different tools and techniques. I learned
how to use functions, conditions, and various data structures like lists and dictionaries. I
also had to handle files and import modules to make everything work together. In the end,
the program was able to show available laptops, update the stock, generate invoices, and
keep track of transactions by modifying the text file. During the project, I faced many
challenges that required me to do a lot of research. I had to browse different websites to
find solutions and learn more about Python programming. Thanks to the support and
guidance from my module teachers, I was able to overcome these difficulties and finish
the task on time. The coursework taught me a lot about Python programming. I learned
how to use functions, conditions, and different types of data like strings, numbers, lists,
and True/False statements. I also learned how to create and modify text files using Python
and how to import and use modules.
Overall, this project was a great learning experience. It helped me improve my research
skills, time management, and ability to stay calm in difficult situations
50
Arpan Karki 22072096
CS4051NT Fundamentals of Computing
9. Appendix
import Add
import Sell
def selectOptions():
try:
flag = True
while flag:
print("""
____________________________________________________
____________Laptop Store____________
____________________________________________________
Press 4 : Exit
51
Arpan Karki 22072096
CS4051NT Fundamentals of Computing
____________________________________________________
____________________________________________________
""")
if selectOption.isdigit():
if selectOption == "1":
displayLaptop(readLaptopList())
print("""
__________________________________________
""")
if userInput == "1":
Sell.sellLaptops(readLaptopList())
print("""
52
Arpan Karki 22072096
CS4051NT Fundamentals of Computing
""")
else:
displayLaptop(readLaptopList())
print("______________________________________________________\n")
Sell.sellLaptops(readLaptopList())
displayLaptop(readLaptopList())
print("_____________________________________________________\n")
Add.addLaptopStock(readLaptopList())
flag = False
print("""
""")
else:
53
Arpan Karki 22072096
CS4051NT Fundamentals of Computing
else:
except ValueError as e:
print(e)
selectOptions()
def readLaptopList():
laptopsList = []
lines = file.readlines()
a = line.strip().split(",")
laptopsList.append(a)
file.close()
54
Arpan Karki 22072096
CS4051NT Fundamentals of Computing
return laptopsList
def displayLaptop(laptopsList):
for i in range(len(laptopsList)):
laptop = laptopsList[i]
laptop.insert(0, i + 1)
headers = [
"S.No.",
"Name",
"Company",
"Price",
"Quantity",
"Generation",
"Graphics Card",
table = laptopsList.copy()
table.insert(0, headers)
print(
55
Arpan Karki 22072096
CS4051NT Fundamentals of Computing
def sellLaptops(laptopsList):
try:
print("__________________________________________\n")
return
56
Arpan Karki 22072096
CS4051NT Fundamentals of Computing
stock = int(laptop[3])
print("\nInsufficient Quantity!!")
return
return
updateStock(laptopsList)
57
Arpan Karki 22072096
CS4051NT Fundamentals of Computing
print("\t____________________________________________________________")
return
print("_________________________________________________________________
______")
print(
"We apologize, but the laptop you are seeking is not currently available."
except ValueError:
def updateStock(laptopsList):
for i in range(len(laptopsList)):
for j in range(6):
if j == 5:
update.write(str(laptopsList[i][j]) + "\n")
else:
update.write(str(laptopsList[i][j]) + ",")
update.close()
58
Arpan Karki 22072096
CS4051NT Fundamentals of Computing
import datetime
import Sell
def addLaptopStock(laptopList):
print("__________________________________________\n")
return
if laptopStock <= 0:
return
59
Arpan Karki 22072096
CS4051NT Fundamentals of Computing
for i in range(len(laptopList)):
if (i+1 == laptopNumber):
a = int(laptopList[i][3])
a += laptopStock
laptopList[i][3] = a
Sell.updateStock(laptopList)
print("_______________________________________\n")
print("_______________________________________________________
__")
k = datetime.datetime.now()
for i in range(len(laptopList)):
60
Arpan Karki 22072096
CS4051NT Fundamentals of Computing
if (i+1 == laptopNumber):
Name = laptopList[i][0]
company = laptopList[i][1]
quantity = laptopList[i][3]
gen = laptopList[i][4]
graphicsCard = laptopList[i][5]
f = open(f, "w")
f.write("\n"+"\t\t________________________________________________
__________________________")
61
Arpan Karki 22072096
CS4051NT Fundamentals of Computing
f.write("\n"+"\t\t________________________________________________
__________________________")
laptopShippingCompany)
str(laptopShippingCost))
str(k.hour)+" : "+str(k.minute))
str(totalAmountWithVat))
62
Arpan Karki 22072096
CS4051NT Fundamentals of Computing
f.write("\n"+"\t\t________________________________________________
__________________________")
f.write("\n"+"\t\t
__________________________________________________ ")
f.write("\n"+"\t\t________________________________________________
__________________________")
f.close()
import datetime
import os.path
selected_laptop = laptopsList[laptopNumber-1]
Name = selected_laptop[0]
company = selected_laptop[1]
63
Arpan Karki 22072096
CS4051NT Fundamentals of Computing
price = selected_laptop[2]
gen = selected_laptop[4]
graphicsCard = selected_laptop[5]
f.write("______________________________________________________
___________\n")
f.write(" Date: {} / {} /
{}\n".format(datetime.datetime.now().year,
datetime.datetime.now().month,
datetime.datetime.now().day))
64
Arpan Karki 22072096
CS4051NT Fundamentals of Computing
f.write(" ________________________\n")
f.write("______________________________________________________
___________\n")
f.write("Name: {}\n".format(Name))
f.write("Company: {}\n".format(company))
f.write("Quantity: {}\n".format(quantity))
f.write("Price: {}\n".format(price))
f.write("Generation: {}\n".format(gen))
f.write("___________________________\n")
f.write("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\n")
65
Arpan Karki 22072096
CS4051NT Fundamentals of Computing
f.write("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \n")
f.close()
print("_______________________________________________________
_______________________")
print("______________________________________")
else:
f.write("______________________________________________________
___________\n")
f.write("Date: {} / {} / {}\n".format(datetime.datetime.now().year,
datetime.datetime.now().month,
datetime.datetime.now().day))
66
Arpan Karki 22072096
CS4051NT Fundamentals of Computing
f.write(
"___________________________________________________________
________ \n")
f.write("Name: {}\n".format(Name))
f.write("Company: {}\n".format(company))
f.write("Quantity: {}\n".format(quantity))
f.write("Price: {}\n".format(price))
f.write("Generation: {}\n".format(gen))
f.write("____________________\n")
f.write("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\n")
f.write("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \n")
67
Arpan Karki 22072096
CS4051NT Fundamentals of Computing
print("_______________________________________________________
_______________________")
print("______________________________________")
f.close()
68
Arpan Karki 22072096
CS4051NT Fundamentals of Computing
10. References
Anderson, 2023. JavaPoint. [Online]
Available at: https://www.javatpoint.com/python-tutorial
[Accessed 11 November 2023].
69
Arpan Karki 22072096
CS4051NT Fundamentals of Computing
11. Report
70
Arpan Karki 22072096