logo

Foundation of Programming I Assignment

   

Added on  2022-08-21

11 Pages1412 Words13 Views
 | 
 | 
 | 
Running head: FOUNDATION OF PROGRAMMING
Foundation of Programming
Students name:
Student ID:
University Name:
Foundation of Programming I Assignment_1

Foundation of Programming2
Table of Contents
Design..............................................................................................................................................3
Test Cases........................................................................................................................................7
Activity Flowchart...........................................................................................................................8
Bibliography....................................................................................................................................9
Appendix 1.....................................................................................................................................10
Foundation of Programming I Assignment_2

Foundation of Programming3
Design
Pseudocode of the program have been shown below-
df=read("addresses.csv") // read the csv file for the analysis
FUNCTION displayMenu(): // function for the welcome message with all details
OUTPUT "\nTOOTH FAIRY - ATO CASE"
OUTPUT "\nRajneet Kaur - 30380674"
OUTPUT "1 Statistics\n2 Export Children details who haven't loss any teeth\n3 Display
number of claims per state\n4 Compare 2 States\n5 Exit\n"
END FUNCTION // End of function displayMenu
FUNCTION part1(): // function for part 1
OUTPUT f"\nTotal number of children on list: {len(df)}\n"
OUTPUT f"Average number of teeth claims over the years: {df['Total number of teeth
lost'].mean()}\n"
OUTPUT f"Number of children who have never lost a tooth: {len(df)-(df['Total number of
teeth lost'].astype(bool).sum(axis=0))}\n"
OUTPUT f"Number of children who have lost all their baby teeth:
{np.count_nonzero((df['Total number of teeth lost']==20))}\n"
sum=0
for i in df["Total number of teeth lost"]:
IF i==1:
sum+=1
ELSE IF i>1:
sum+=.5
END IF
END FOR
OUTPUT f"Total expenditure for this year: ${sum}"
END FUNCTION // End of function part1
FUNCTION part2(): //function for part2
Foundation of Programming I Assignment_3

Foundation of Programming4
x=input("Enter the name of the file with extension? ")
df1=df[df['Total number of teeth lost'] ==0]
with open(x, 'a') as f:
f.write(df1.to_string(header <- True, index <- False))
OUTPUT f"\n17 childrens have been saved in {x}"
END FUNCTION // End of function part2
FUNCTION part3(): // function for part 3
l1=df["State"].unique()
l2=df["State"].value_counts()
l3=[]
for i in l1:
l3.append(l2[i])
END FOR
num_bars=len(l2)
positions=range(1,num_bars+1)
plt.bar(positions,l3,align='center')
plt.xticks(positions,l1)
plt.xlabel("State")
plt.ylabel("Number of Childrens")
plt.title("Number of Childrens per State")
plt.grid()
plt.show()
END FUNCTION End of function part3
FUNCTION part4(): // function for part4
l2=df["State"].value_counts()
a=input("Enter the first state ('TAS', 'QLD', 'WA', 'NSW', 'SA', 'ACT', 'VIC', 'NT'): ").upper()
Foundation of Programming I Assignment_4

End of preview

Want to access all the pages? Upload your documents or become a member.