Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Well done!
You have completed Plan Ahead with Pseudocode!
You have completed Plan Ahead with Pseudocode!
Preview
Expand your pseudocode vocabulary with some simple conventions for describing loops.
Pseudocode for loops
retrieve student_grades
set grades to student_grades
set grade_total to 0
for each grade in grades
if grade is not a 1, 2, 3, or 4
print "invalid grade"
print grade
print "can't complete calculation"
stop
else add grade to grade_total
endif
endfor
set gpa to grade_total / number of grades
print gpa
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
functions, using
easy-to-understand language.
0:00
I'll start with loops in this video and
continue with functions in the next.
0:00
If you want to follow along, open the
workspace associated with this video and
0:04
the file named gpa.txt.
0:08
Given a list of student grades,
calculate their GPA.
0:13
The grading scale used should be 1 to 4.
0:15
If any grade isn't a 1, 2, 3, or 4,
print a message and stop the program.
0:18
Say you're creating a GPA calculator
that takes a student's grades and
0:25
determines their overall
grade point average.
0:28
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up