Toll System Assignment: Data Science, Big Data, Python, and Tolls

Verified

Added on  2020/05/28

|5
|421
|60
Homework Assignment
AI Summary
This assignment focuses on analyzing a toll system using data science techniques and Python programming. The solution includes Python code to read data from a file, search for specific car records based on car numbers, and display the relevant toll information. The program defines functions to calculate the number of lines in the file and uses lists to store and manipulate the data. It also includes error handling for invalid input, such as incorrect car number lengths. The program allows the user to input a car number to search for, providing a user-friendly interface. The provided solution demonstrates how to process and analyze data from a toll system, making it a valuable resource for students studying data science and related fields. The assignment showcases practical applications of programming and data analysis in a real-world scenario. The code is designed to efficiently search and retrieve specific records, providing a practical solution for managing and analyzing toll data.
Document Page
Running head: TOLL SYSTEM
Toll System
Name of Student:
Name of the University:
Author note:
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
1
TOLL SYSTEM
Nassi-Shneiderman algorithm diagram
Document Page
2
TOLL SYSTEM
Python Source code
list=[] #list to store the valid lines from the file
record=[] #list to store the individual fields from each line
listLength=0
#Function to calculate the number of lines in the record file
def findLength():
length=0
with open("tollCharges.txt") as file:
for line in file:
length+=1
return length
length=findLength() #call function to find the number of lines in file
with open("tollCharges.txt") as file:
for i in range(0,length):
line=file.readline() #break every line from the file
record = line.split(" ") #split each field in the entries from the line and store
if len(record[0])==6: #check the first index of the field list
Document Page
3
TOLL SYSTEM
listLength+=1
list.append(line) #add those lines to the list that have car number with 6 characters
i+=1
print()
search="abc" #assign default search value to bypass loop check
while search!= "":
i=0
flag=0
search = input("--------------------------------------\nEnter car number to search for: ")
if(len(search)!=6 and search!=""):
print("ERROR!! Invalid entry. Try again...\n") #check if length of searched Car ID is 6
continue
if search != "": #check if user enters a value
print("\nThe records for",search,"are:\n")
for i in range(0,listLength):
record = list[i].split(" ")
if record[0]==search:
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
4
TOLL SYSTEM
flag=1 #set flag to 1 if searched item is found
print(list[i])
if flag==0:
print("No Toll record is found for",search,"\n")
else: #when user presses ENTER without a value
print("\nYou chose to exit.\nThank you for using our system!!") #exit
#End of program
Output
chevron_up_icon
1 out of 5
circle_padding
hide_on_mobile
zoom_out_icon
[object Object]