# Foundation of Programming I Assignment

11 Pages1412 Words13 Views
|
|
|
Foundation of Programming
Students name:
Student ID:
University Name:
Foundation of Programming2
Design..............................................................................................................................................3
Test Cases........................................................................................................................................7
Activity Flowchart...........................................................................................................................8
Bibliography....................................................................................................................................9
Appendix 1.....................................................................................................................................10
Foundation of Programming3
Design
Pseudocode of the program have been shown below-
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 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()

## End of preview

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

### Support

#### +1 306 205-2269

Chat with our experts. we are online and ready to help.