User:Praveer-mathur-9f3d@uni-bonn.de/python-on-hpc
< User:Praveer-mathur-9f3d@uni-bonn.de
Jump to navigation
Jump to search
Revision as of 15:06, 18 March 2026 by Praveer-mathur-9f3d@uni-bonn.de (talk | contribs)
Short Quiz: Python Packages
Which of these locations will Python search for packages by default?
Short Quiz: Virtual Environments
Which of the following statements is true?
Short Quiz: Conda vs. Pip
To which package manager do the statements apply? pip, conda, neither or both?
"Non-Python packages available by default"
"Tightly integrated with its own virtual environment feature"
"Built-in third-party package repositories"
"Installs new Python executable into env by default"
"Automatically installs dependencies for requested package"
"Requires you to specify package version"
Short Quiz: Arrays and Performance
What should you always do before you optimize your code's performance? (Hard to implement).
Short Quiz: Array Memory Layout
Which index varies fastest in a row-major layout, which varies fastest in a
column-major layout? (Hard to implement).
Which ordering do NumPy arrays have by default? More than one answer
may be correct.
Short Quiz: Array Shapes, Broadcasting
Consider the following code. What does each print statement output? Could be an error. Treat all print statements independently. (Hard to implement)
x = np.zeros(5)
y = np.zeros((3, 5))
z = np.zeros((5, 3, 1))
print((x + y).shape)
print((x + z).shape)
print((y + z).shape)
print(y[:2, :2].shape)
print(y[:2].shape)
print((y[:2] + x[:2]).shape)
print((y[..., np.newaxis] + z).shape)
print((y.ravel() + x[0]).shape)
Short Quiz: Advanced Indexing
Consider the following code. What does each print statement output? Could be an error. Treat all print statements independently.
a = np.array([[1, 2, 3] [4, 5, 6]])
idx = np.array([0, 0])
mask = np.array([False, True, True])
print(a[idx])
print(a[:, idx])
print(a[idx, :])
a[:, mask] = -1
print(a)