Nov-27-2019, 10:47 AM
(This post was last modified: Nov-27-2019, 11:21 AM by StillAnotherDave.)
(Nov-27-2019, 10:17 AM)perfringo Wrote: Input returns string. You are trying to perform power of two (and other math operations) on string.
Ah okay. I need to add an int conversion. Fab!!
Almost there ?
import numpy as np polynomial = np.polynomial.polynomial p1 = polynomial([2, 3, 1]) p2 = polynomial([1, 2, 1]) p3 = polynomial([10, 1, 2]) roots_1 = p1.roots() roots_2 = p2.roots() roots_3 = p3.roots()Why does this return, "module object is not callable"?
(Nov-27-2019, 10:47 AM)StillAnotherDave Wrote:(Nov-27-2019, 10:17 AM)perfringo Wrote: Input returns string. You are trying to perform power of two (and other math operations) on string.
Ah okay. I need to add an int conversion. Fab!!
Almost there ?
import numpy as np polynomial = np.polynomial.polynomial p1 = polynomial([2, 3, 1]) p2 = polynomial([1, 2, 1]) p3 = polynomial([10, 1, 2]) roots_1 = p1.roots() roots_2 = p2.roots() roots_3 = p3.roots()Why does this return, "module object is not callable"?
Resolved: it seems to work if I code as follows
p1 = np.poly1d([2, 3, 1]) p2 = np.poly1d([1, 2, 1]) p3 = np.poly1d([10, 1, 2]) roots_p1 = p1.r roots_p2 = p2.r roots_p3 = p3.r
Thank you all for the help so far.
The final part of the homework I can't figure out:
results = np.array([[54, 1, 0], [56, 0, 1], [72, 0, 0], [34, 3, 0]]) names = np.array(['Amy', 'Bob', 'Carol', 'Dave']) progresses = np.array([(avg >= 40) and (hard_fail == 0) for (avg, soft_fail, hard_fail) in results])1. By applying a logical array to select array indices, extract the rows from your array results relating to just the data for the students who have failed. Also extract the names of the students who have failed from names.
2. Ask the user to choose a row number 1, 2, 3 or 4, storing the result as an integer. Use the result to extract, from names and results respectively, the name of the student in the chosen row and the data for that student.