Skip to content

Commit

Permalink
Added checkpoint 1 to Scipy.ipynb
Browse files Browse the repository at this point in the history
  • Loading branch information
nwhitsett committed Jan 21, 2025
1 parent 07b8aa2 commit d496734
Show file tree
Hide file tree
Showing 3 changed files with 403 additions and 206 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1016,7 +1016,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "base",
"display_name": "exocore",
"language": "python",
"name": "python3"
},
Expand All @@ -1030,7 +1030,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.10"
"version": "3.12.4"
}
},
"nbformat": 4,
Expand Down
402 changes: 389 additions & 13 deletions ExoCore/Curriculum/Data_Structures/Scipy.ipynb

Large diffs are not rendered by default.

203 changes: 12 additions & 191 deletions ExoCore/Exercise_Solutions/Module_3/SciPy/Checkpoints/questions.json
Original file line number Diff line number Diff line change
@@ -1,220 +1,41 @@
[
{
"question": "Which of the following will invert the elements of an array, `arr`?",
"question": "Using CODATA 2022, what is the mass of a resting alpha particle, in MeV?",
"type": "multiple_choice",
"answers": [
{
"answer": "arr = arr[-1]",
"correct": false,
"feedback": "Incorrect. This returns only the last element."
},
{
"answer": "arr = arr[::-1]",
"correct": true,
"feedback": "Correct!"
},
{
"answer": "arr = arr[1:]",
"correct": false,
"feedback": "Incorrect. This returns the same array, excluding the first value."
},
{
"answer": "arr = arr[3::-1]",
"correct": false,
"feedback": "Incorrect. This returns an array from the fourth element back to the first element."
}
]
},
{
"question": "Which list comprehension syntax will exclude all negative elements, and multiply the remaining elements in an array, `arr`, by 1.5 times?",
"type": "multiple_choice",
"answers": [
{
"answer": "arr = [x*1.5 for x in arr if x < 0]",
"correct": false,
"feedback": "Incorrect. Almost! This will exclude all positive elements, not negative."
},
{
"answer": "arr = [x/2 for x in arr if np.abs(x) <= 0]",
"correct": false,
"feedback": "Incorrect. This divides all elements by two, and doesn't exclude any values!"
},
{
"answer": "arr = [x*1.5 for x in arr if x > 0]",
"correct": true,
"feedback": "Correct!"
},
{
"answer": "arr = [x*1.5 for x in arr]",
"correct": false,
"feedback": "Incorrect. This gets close, but does not exclude negative values."
}
]
},
{
"question": "What conditional would you pass to check if a value, x, is NAN?",
"type": "multiple_choice",
"answers": [
{
"answer": "if x == np.nan",
"correct": false,
"feedback": "Incorrect. Since NANs are not a string, number, or int, checking exactness is not well defined."
},
{
"answer": "if np.isnan(x) == 'True'",
"correct": false,
"feedback": "Incorrect. The returned value form np.isnan() is a Bool, not a string."
},
{
"answer": "if np.isnan(x) == True",
"correct": true,
"feedback": "Correct!"
},
{
"answer": "if x == 'nan'",
"correct": false,
"feedback": "Incorrect. The RHS is a string, not a np.nan object. Additionally, '==' conditional does not work to check if a value is NAN."
}
]
},
{
"question": "Which array creation method will create a 4x30 array, with each element being `45`?",
"type": "multiple_choice",
"answers": [
{
"answer": "np.ones((4, 30), value=45)",
"correct": false,
"feedback": "Incorrect. While np.ones is on the right track and the dimensions are correct, passing `value=45` will not work."
},
{
"answer": "np.ones((4, 30))*45",
"correct": true,
"feedback": "Correct!."
},
{
"answer": "np.linspace((4, 30))*40",
"correct": true,
"feedback": "Incorrect. Linspace creates evenly spaced arrays from the start and end value."
},
{
"answer": "np.zeros((4,30)) + np.ones((4,30))",
"correct": false,
"feedback": "Incorrect. While this gives the right shape, the values will be 1s, and the zero array is unnecessary."
}
]
},
{
"question": "np.argmax(array) will return the highest value in the array.",
"type": "multiple_choice",
"answers": [
{
"answer": "True",
"correct": false,
"feedback": "Incorrect. It will return the index of the highest value."
},
{
"answer": "False",
"correct": false,
"feedback": "Correct!"
}
]
},
{
"question": "What method allows you to take three arrays, arr1, arr2, arr3, and export them as a three columned csv file?",
"type": "multiple_choice",
"answers": [
{
"answer": "np.hstack((arr1, arr2, arr3)).T",
"correct": false,
"feedback": "Incorrect. hstack will stack all arrays into a single column."
},
{
"answer": "np.vstack((arr1,arr2,arr3))",
"correct": false,
"feedback": "Incorrect. Close, but you need to transpose."
},
{
"answer": "np.vstack((arr1,arr2,arr3)).T",
"answer": "3727.38 MeV",
"correct": true,
"feedback": "Correct!"
},
{
"answer": "np.array((arr1,arr2,arr3))",
"answer": "2240.12 MeV",
"correct": false,
"feedback": "Incorrect, this creates a new array with the three arrays inside of a tuple."
}
]
},
{
"question": "np.argmax(array) will return the highest value in the array.",
"type": "multiple_choice",
"answers": [
{
"answer": "True",
"correct": false,
"feedback": "Incorrect. It will return the index of the highest value."
"feedback": "Incorrect."
},
{
"answer": "False",
"correct": false,
"feedback": "Correct!"
}
]
},
{
"question": "How do you call a random normal variate with mean 10 and variance 16?",
"type": "multiple_choice",
"answers": [
{
"answer": "np.random.normal(loc = 16, scale = 10)",
"answer": "1.00 MeV",
"correct": false,
"feedback": "Incorrect. `loc` specifies the mean, and scale specifies the standard deviation."
"feedback": "Incorrect."
},
{
"answer": "np.random.normal(loc = 10, scale = 4)",
"answer": "0.511 MeV",
"correct": false,
"feedback": "Correct!"
},
{
"answer": "np.random.normal(loc = 10, scale = 16)",
"correct": true,
"feedback": "Incorrect. While the mean is correct, the scale is the standard deviation, not variance."
},
{
"answer": "np.random.random(loc = 10, scale = 4)",
"correct": false,
"feedback": "Incorrect. np.random.random creates a random variate between [0, 1), and does not specify the passed arguments."
"feedback": "Incorrect. This is the mass equivalent for a beta particle/electron at rest."
}
]
},
{
"question": "NumPy has methods to support a quartic fit.",
"type": "multiple_choice",
"answers": [
{
"answer": "True",
"correct": false,
"feedback": "Correct!"
},
{
"answer": "False",
"correct": false,
"feedback": "Incorrect. This can be done using np.polynomial.polynomial.polyfit(x,y,4)"
}
]
},
{
"question": "In the system of equation below, what is the sum of x0, x1, and x2? Use np.linalg.solve.",
"question": "What is the integral of the function below?",
"type": "numeric",
"precision": 3,
"precision": 4,
"answers": [
{
"type": "value",
"value": "-0.125",
"value": 1.885,
"correct": true,
"feedback": "Correct"
"feedback": "Correct!"
}

]
}
]

0 comments on commit d496734

Please sign in to comment.