AMATH Quiz 3

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/16

flashcard set

Earn XP

Description and Tags

If statements; For loops; Plotting data; Python functions and anonymous functions

Last updated 5:22 PM on 1/30/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

17 Terms

1
New cards

Write a for loop over an array.

for variable in np.arange(array):
    #Formula or command goes here

2
New cards

Where does np.arange(x) start and end?

It starts at 0 and ends at x-1

3
New cards

Write a for loop using range .

for variable in range(range):
    #Formula or command goes here

4
New cards

Which is preferable when creating a for loop that increases by 1 each time? range or np.arange() ?

range is preferred

5
New cards

What does a for loop do?

It is an efficient way of repeatedly doing the same process on different parts of a variable

6
New cards

Create an array of 6 zeros in Python using np.zeros()

N = np.zeros(6)

7
New cards

What does np.zeros(x) do?

It creates an array with x amount of zeroes

8
New cards

Populate a 1D array using a for loop.

for year in range(years + 1):
    if np.isin(year, count_years):
        model_pop[model_pop_index] = model_calculation #Think f(x) = function. model_pop is the array

9
New cards

Create a plot with markers from two arrays.

fig, ax = plt.subplots()
ax.plot(x, y, marker = 'o', linestyle = 'None')
ax.plot(x, z, marker = 'o', linestyle = 'None')

10
New cards

What do markers do?

They show the data you have

11
New cards

When should you ONLY use markers on a plot?

When you don’t have enough data for a graph to smoothly connect from one point to the next.

12
New cards

How do functions improve modularity and reusability?

They provide an efficient way to find different information using the same variables without changing them every time.

13
New cards

Create and call python functions.

def f(x):
    y = x**2 + 3 
    return y  


# Use the function f
f_output = f(2)
print("The function f says that f(2) =", f_output)

14
New cards

When is a variable a LOCAL variable?

When it is INSIDE a function.

15
New cards

When is a variable a GLOBAL variable?

When it is OUTSIDE of a function

16
New cards

Solve for f(x) = x² + 3 when x = 2 using anonymous functions.

f = lambda x: x**2 + 3
print(f(2))

17
New cards

Solve for x + y when x = a and y = b

add_two_numbers = lambda x, y: x+y

a = 2
b = 3
print(add_two_numbers(a, b))