Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python Basic Math for Data Analysis Welcome to Basic Math for Data Analysis Percentages

Anthony Nemetz
Anthony Nemetz
1,717 Points

for grade in test_grade

All of the math concepts are familiar to me, The part I am lost with is where - for grade in test_grade: - somehow pulls the proper number of grades above 70. Is grades a specified term? is it a part of the code that I am not seeing? the percentages and math all make sense, I am just unaware what is telling this to go up and look for this properly.

thanks!

1 Answer

Joseph Yhu
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Joseph Yhu
PHP Development Techdegree Graduate 48,463 Points

Are you familiar with for loops?

for grade in test_grades:
    if grade >= 70:
        passed += 1

This is an example of a for loop in Python; grade is just used as a reference to each item in the test_grades list. First time through the loop, grade would equal 98 because that's the first item in the list for example. Second time, grade would equal 100, third time 54, etc.

Anthony Nemetz
Anthony Nemetz
1,717 Points

Thank you! That's what I was looking for