Potter1245 Posted February 27, 2021 Posted February 27, 2021 The data in the table below has been collected by a teacher at the end of two unit assessments. Produce a subroutine for an algorithm that could be used to count the number of students who achieved a grade 8 in both assessments, the data is stored in parallel arrays and array indexing begins at 0 Ryan. 5. 5 Liam. 8. 8 Sophie. 5. 7 Micheal 3. 4 Robert 8. 8 Rebecca. 5. 3
studiot Posted February 27, 2021 Posted February 27, 2021 You haven't said if the information in each line is all one string or in columns or what ? In any case you need to start by telling us what you have done or think might be done. Hint : I would start with the last character in each line
Ghideon Posted February 27, 2021 Posted February 27, 2021 May we assume 8 is the highest grade? 16 minutes ago, Potter1245 said: data is stored in parallel arrays and array indexing begins at 0 I'll assume that you have two arrays containing 6 integers each: 5, 8, 5, 3, 8, 5 and 5, 8, 7, 4, 8, 3 As a stating point, do you know how to loop through arrays and use the index to access values?
Potter1245 Posted February 27, 2021 Author Posted February 27, 2021 8 is the highest grade, I don’t know how to loop guys, pls help My daughter has asked me to answer this question as a dad I said I’ll try, I have no idea, but you guys are experts I’ll try anything
Ghideon Posted February 27, 2021 Posted February 27, 2021 (edited) 31 minutes ago, Potter1245 said: 8 is the highest grade Thanks! Now, let's say we have both the grades for a student, any idea how we could find out if both grades are 8? You could answer something in plain English like "if grade is this then do this..." 31 minutes ago, Potter1245 said: I don’t know how to loop guys, pls help A loop in this case means some way the algoritm uses to go through the array(s), step by step. A loop may be useful to check grades and do counting. Below is an example of a loop. It means: "go through the grades, one by one, and do something." In this case it prints the grades. grades = [5, 8, 5, 3, 8, 5 ] for x in grades: print(x) The above can be copy-pasted into an online tool such as w3schools* if you want to test. *) in chis specific case you may start here: https://www.w3schools.com/python/trypython.asp?filename=demo_for Edited February 27, 2021 by Ghideon edit in progress
Sensei Posted March 16, 2021 Posted March 16, 2021 (edited) On 2/27/2021 at 5:28 PM, Ghideon said: The above can be copy-pasted into an online tool such as w3schools* if you want to test. ..but OP didn't say the answer should be in Python... Edited March 16, 2021 by Sensei
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now