ITECH1400 Assignment 2: ATO Tooth Fairy Program Solution
VerifiedAdded on  2022/08/21
|12
|1191
|15
Homework Assignment
AI Summary
This assignment solution presents a Python program designed to analyze data from the Australian Tax Office (ATO) related to the Tooth Fairy. The program utilizes the Pandas library to read and process data from a CSV file, offering functionalities such as calculating statistics (mean, count of children), exporting specific data to files, plotting claims per state, and comparing claims between two states. The program's structure includes pseudocode outlining the logic, followed by the Python code implementation. The solution also includes test cases to validate the program's functionality, demonstrating the expected outputs for various scenarios. The student has implemented a menu-driven interface for user interaction, allowing users to select different options for data analysis and visualization. The solution addresses the assignment brief's requirements by providing a functional and well-documented program that effectively analyzes the provided data and presents the results.

Running head: ITECH1400 FUNDAMENTALS OF PROGRAMMING: AUSTRALIAN TAX OFFICE (ATO)
ITECH1400 Fundamentals of Programming: Australian Tax Office (ATO)
Name of the Student
Name of the University
Authors note
ITECH1400 Fundamentals of Programming: Australian Tax Office (ATO)
Name of the Student
Name of the University
Authors note
Paraphrase This Document
Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser

1ITECH1400 FUNDAMENTALS OF PROGRAMMING: AUSTRALIAN TAX OFFICE (ATO)
Pseudocode
1. using pandas read CSV input file.
3. Ask user to enter choice among the 1 for Statistics, 2 for exporting details, 3 to plot
claims of all states, 4 to plot comparison of two plots and 5 exit.
4. Display menu
5.User selects option 1;
6. Calculate mean of tooth lost, calculate count of rows with 0 value in tooth lost
column of the data frame.
7.Print results.
8.User choses 2
9.Prompt user to enter file name
10. Create a data frame about the children who have 0 as value in tooth lost column.
11.Write the data frame in the file.
12. User input is 3
13. Group by the name of states from the data frame and calculate the total tooth lost for
different group and plot.
14. User enters 4
15. User will be asked to enter one of states among the list of states
16. User will be asked to enter another of states among the list of states
Pseudocode
1. using pandas read CSV input file.
3. Ask user to enter choice among the 1 for Statistics, 2 for exporting details, 3 to plot
claims of all states, 4 to plot comparison of two plots and 5 exit.
4. Display menu
5.User selects option 1;
6. Calculate mean of tooth lost, calculate count of rows with 0 value in tooth lost
column of the data frame.
7.Print results.
8.User choses 2
9.Prompt user to enter file name
10. Create a data frame about the children who have 0 as value in tooth lost column.
11.Write the data frame in the file.
12. User input is 3
13. Group by the name of states from the data frame and calculate the total tooth lost for
different group and plot.
14. User enters 4
15. User will be asked to enter one of states among the list of states
16. User will be asked to enter another of states among the list of states

2ITECH1400 FUNDAMENTALS OF PROGRAMMING: AUSTRALIAN TAX OFFICE (ATO)
17. Plot bar graph for the two states.
9.Display menu again until user enters 5.
10. User Selects 5, exit function.
11. Else go to 4.
Test Case
Test Case ID Description Expected Output Comment
#1 User Selects option 1
to display Statistics
of the Records
Details of total
records, mean value,
count of children who
had lost baby teeth,
zero teeth and total
payable amount is
depicted.
Test passed.
#2 User enters 2 to
export details of
children who never
lost a tooth in the
provided file name
Records are saved in
the user provided file.
Pass
#3 User enters 3 to plot
the claims for all the
states.
Plot of comparing the
loss of tooth for
different states is
Pass
17. Plot bar graph for the two states.
9.Display menu again until user enters 5.
10. User Selects 5, exit function.
11. Else go to 4.
Test Case
Test Case ID Description Expected Output Comment
#1 User Selects option 1
to display Statistics
of the Records
Details of total
records, mean value,
count of children who
had lost baby teeth,
zero teeth and total
payable amount is
depicted.
Test passed.
#2 User enters 2 to
export details of
children who never
lost a tooth in the
provided file name
Records are saved in
the user provided file.
Pass
#3 User enters 3 to plot
the claims for all the
states.
Plot of comparing the
loss of tooth for
different states is
Pass
⊘ This is a preview!⊘
Do you want full access?
Subscribe today to unlock all pages.

Trusted by 1+ million students worldwide

3ITECH1400 FUNDAMENTALS OF PROGRAMMING: AUSTRALIAN TAX OFFICE (ATO)
presented.
#4 User wants to plot
comparison chart of
two states
After entering two
state names plot is
displayed.
Passed.
#5 User enters any other
option except 1to 5.
Program presents an
error message and
asks user to enter
only among the
options.
Successfully presents
the menu after invalid
input.
Passed
presented.
#4 User wants to plot
comparison chart of
two states
After entering two
state names plot is
displayed.
Passed.
#5 User enters any other
option except 1to 5.
Program presents an
error message and
asks user to enter
only among the
options.
Successfully presents
the menu after invalid
input.
Passed
Paraphrase This Document
Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser

4ITECH1400 FUNDAMENTALS OF PROGRAMMING: AUSTRALIAN TAX OFFICE (ATO)
Activity chart
Activity chart

5ITECH1400 FUNDAMENTALS OF PROGRAMMING: AUSTRALIAN TAX OFFICE (ATO)
Program
import pandas as pd
import matplotlib.pyplot as plt
%matplotlib inline
dataframe = pd.read_csv('addresses.csv')
totalrecords= len(dataframe.index)
def summaryfunc():
df1 = dataframe.apply(lambda tet: True if 0 in list(tet) else False, axis=1)
df1count = len(df1[df1 == True].index)
df2 = dataframe.apply(lambda tet: True if 20 in list(tet) else False, axis=1)
df2count = len(df2[ df2 == True].index)
df3 = dataframe.apply(lambda tet: True if 1 in list(tet) else False, axis=1)
df3count = len(df3[df3 == True].index)
final = totalrecords - df1count - df3count
payment = (final * .5) + df3count-(df2count*.5)
print("Total children records in address.csv file : ", totalrecords)
print("Average claim of Tooth", dataframe['Total number of teeth lost'].mean())
Program
import pandas as pd
import matplotlib.pyplot as plt
%matplotlib inline
dataframe = pd.read_csv('addresses.csv')
totalrecords= len(dataframe.index)
def summaryfunc():
df1 = dataframe.apply(lambda tet: True if 0 in list(tet) else False, axis=1)
df1count = len(df1[df1 == True].index)
df2 = dataframe.apply(lambda tet: True if 20 in list(tet) else False, axis=1)
df2count = len(df2[ df2 == True].index)
df3 = dataframe.apply(lambda tet: True if 1 in list(tet) else False, axis=1)
df3count = len(df3[df3 == True].index)
final = totalrecords - df1count - df3count
payment = (final * .5) + df3count-(df2count*.5)
print("Total children records in address.csv file : ", totalrecords)
print("Average claim of Tooth", dataframe['Total number of teeth lost'].mean())
⊘ This is a preview!⊘
Do you want full access?
Subscribe today to unlock all pages.

Trusted by 1+ million students worldwide

6ITECH1400 FUNDAMENTALS OF PROGRAMMING: AUSTRALIAN TAX OFFICE (ATO)
print('Number of children with zero teeth loss : ', df1count)
print("Total number of children lost one teeth", df3count)
print("Count of children who lost all baby teeth", df2count)
print("Total expenditure for is $", payment)
def exportfiles():
export = input("Enter File Name to store Records \n")
openf = open(export, 'a')
matchframe = dataframe[dataframe['Total number of teeth lost'] == 0]
childflen=len(matchframe)
strngd=matchframe.to_string()
openf.write(strngd)
openf.close()
print("{0} Records are Saved in {1}".format(childflen,export))
def menufuncrep():
print("-------------------WELCOME TOOTH FAIRY--ATO CASE-------------------")
print("--------------STUDENT NAME: Mohammed Huzaifa Obaid ----------------------")
print("--------------STUDENTID: 30358937 ---------------------------------------")
print("SELECT AND ENTER YOUR CHOICE FROM THE FOLLOWING
OPTIONS \n")
print('Number of children with zero teeth loss : ', df1count)
print("Total number of children lost one teeth", df3count)
print("Count of children who lost all baby teeth", df2count)
print("Total expenditure for is $", payment)
def exportfiles():
export = input("Enter File Name to store Records \n")
openf = open(export, 'a')
matchframe = dataframe[dataframe['Total number of teeth lost'] == 0]
childflen=len(matchframe)
strngd=matchframe.to_string()
openf.write(strngd)
openf.close()
print("{0} Records are Saved in {1}".format(childflen,export))
def menufuncrep():
print("-------------------WELCOME TOOTH FAIRY--ATO CASE-------------------")
print("--------------STUDENT NAME: Mohammed Huzaifa Obaid ----------------------")
print("--------------STUDENTID: 30358937 ---------------------------------------")
print("SELECT AND ENTER YOUR CHOICE FROM THE FOLLOWING
OPTIONS \n")
Paraphrase This Document
Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser

7ITECH1400 FUNDAMENTALS OF PROGRAMMING: AUSTRALIAN TAX OFFICE (ATO)
menuoptn = (""" 1: STATISTICS ABOUT THE STORED RECORDS \n
2: EXPORTING DETAILS TO A FILE ABOUT THE CHILDREN WHO
NEVER LOST TEETH \n
3: DISPLAY AND PLOT NUMBER OF CLAIMS PER STATE \n
4: COMPARE 2 STATES IN BY COUNTING THE LOST TEETH \n
5: EXIT THE PROGRAM
\t \n """)
userinput = input(menuoptn)
return int(userinput)
while True:
funcchoice= menufuncrep()
if funcchoice == 1:
summaryfunc()
elif funcchoice == 2:
exportfiles()
elif funcchoice == 3:
menuoptn = (""" 1: STATISTICS ABOUT THE STORED RECORDS \n
2: EXPORTING DETAILS TO A FILE ABOUT THE CHILDREN WHO
NEVER LOST TEETH \n
3: DISPLAY AND PLOT NUMBER OF CLAIMS PER STATE \n
4: COMPARE 2 STATES IN BY COUNTING THE LOST TEETH \n
5: EXIT THE PROGRAM
\t \n """)
userinput = input(menuoptn)
return int(userinput)
while True:
funcchoice= menufuncrep()
if funcchoice == 1:
summaryfunc()
elif funcchoice == 2:
exportfiles()
elif funcchoice == 3:

8ITECH1400 FUNDAMENTALS OF PROGRAMMING: AUSTRALIAN TAX OFFICE (ATO)
grpdf = dataframe.groupby('State').nunique()
grpdf['First Name'].plot.bar()
plt.show()
elif funcchoice == 4:
input1 = input("Enter Nama of one State from the follo \n NSW/ NT/SA/TAS VIC/
ACT/ WA/QLD/ \n")
input2 = input("Enter Second state to compare among the following list of States \n
NSW/VIC/WA/QLD/ACT/NT/SA/TAS \n")
df1 = dataframe.apply(lambda state: True if statename in list(state) else False,
axis=1)
df2 = dataframe.apply(lambda state: True if statename1 in list(state) else False,
axis=1)
mpdat1 = len(df1[df1 == True].index)
mpdat2 = len(df2[df2 == True].index)
pdx = [mpdat1, mpdat2]
plt.bar([input1, input2], pdx)
plt.show()
elif funcchoice == 5:
grpdf = dataframe.groupby('State').nunique()
grpdf['First Name'].plot.bar()
plt.show()
elif funcchoice == 4:
input1 = input("Enter Nama of one State from the follo \n NSW/ NT/SA/TAS VIC/
ACT/ WA/QLD/ \n")
input2 = input("Enter Second state to compare among the following list of States \n
NSW/VIC/WA/QLD/ACT/NT/SA/TAS \n")
df1 = dataframe.apply(lambda state: True if statename in list(state) else False,
axis=1)
df2 = dataframe.apply(lambda state: True if statename1 in list(state) else False,
axis=1)
mpdat1 = len(df1[df1 == True].index)
mpdat2 = len(df2[df2 == True].index)
pdx = [mpdat1, mpdat2]
plt.bar([input1, input2], pdx)
plt.show()
elif funcchoice == 5:
⊘ This is a preview!⊘
Do you want full access?
Subscribe today to unlock all pages.

Trusted by 1+ million students worldwide

9ITECH1400 FUNDAMENTALS OF PROGRAMMING: AUSTRALIAN TAX OFFICE (ATO)
print(" THANK YOU FOR USING THE PROGRAM of TOOTH FAIRY BY ATO\
t")
break
else:
print(" Invalid Input!!! Try again with Valid Input choice ")
Test Cases and Results
Test case 1
Test case 2
print(" THANK YOU FOR USING THE PROGRAM of TOOTH FAIRY BY ATO\
t")
break
else:
print(" Invalid Input!!! Try again with Valid Input choice ")
Test Cases and Results
Test case 1
Test case 2
Paraphrase This Document
Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser

10ITECH1400 FUNDAMENTALS OF PROGRAMMING: AUSTRALIAN TAX OFFICE (ATO)
Test case 3
Test case 4
Test case 3
Test case 4

11ITECH1400 FUNDAMENTALS OF PROGRAMMING: AUSTRALIAN TAX OFFICE (ATO)
Test case 5
Test case 5
⊘ This is a preview!⊘
Do you want full access?
Subscribe today to unlock all pages.

Trusted by 1+ million students worldwide
1 out of 12

Your All-in-One AI-Powered Toolkit for Academic Success.
 +13062052269
info@desklib.com
Available 24*7 on WhatsApp / Email
Unlock your academic potential
Copyright © 2020–2025 A2Z Services. All Rights Reserved. Developed and managed by ZUCOL.