0% found this document useful (0 votes)
7 views4 pages

PF Assignment

Uploaded by

Leonel Messi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views4 pages

PF Assignment

Uploaded by

Leonel Messi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

HOMEWORK (FLOWCHART AND ALGORITHM)

1. Calculate the sum of all elements in a list.

Algorithm:

• Start with a number Total, Total =0.


• Look at the first number in the list.
• Add it to total.
• Move to the next number.
• Repeat step 3 until there are no numbers left.
• The total is the sum of all the numbers.

Flowchart:

2. Calculate the number of occurrences of a specific number or element in a list.

Algorithm:

• Start.
• Set a counter = 0.
• Observe the first number in the list.
• If it is equal to the target number then add 1 to the counter.
• Move to the next number.
• Repeat steps 3 to 5 until no numbers are left.
• Print counter as the result.
• End.

Flowchart:

Algorithm:
• Start.
• Set total = 0.
• Set student_count = 0.
• For each student in the class:
• Take test1, test2, test3 marks.
• Calculate student_average = (test1 + test2 + test3) ÷ 3.
• Add student average to total.
• Increase student_count by 1.
• When all students are processed:
• class_average = total ÷ student_count.
• Print class_average.
• End.
Flowchart

You might also like