Basics and Calculations - AMATH 301 Exam 1

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

1/32

encourage image

There's no tags or description

Looks like no tags are added yet.

33 Terms

1
New cards

What does = mean in Python?

Assignment: store the right-hand value in the left-hand variable.

2
New cards

What does ** mean?

Exponentiation: 3**2 is 9

3
New cards

How do you write 3 times x?

3*x (multiplication needs *)

4
New cards

How do you write sqrt(x) with NumPy?

np.sqrt(x)

5
New cards

How do you write pi with NumPy?

np.pi (no parentheses)

6
New cards

How do you write e raised to x?

np.exp(x)

7
New cards

How do you write the natural log of x?

np.log(x)

8
New cards

How do you write sin(x) and cos(x)?

np.sin(x) and np.cos(x), with angles in radians

9
New cards

Translate (3 + e^2)/4 into NumPy

(3 + np.exp(2))/4

10
New cards

What does x=4; x=x+3; print(x) output?

7; the previous value of x is increased by 3

11
New cards

Why does calculation order matter?

Python runs assignments in order; a variable must exist before use

12
New cards

What does print("x={}".format(5)) display?

x=5

13
New cards

What does .format(a,b) do with two {} blanks?

Fills them left-to-right with a and b

14
New cards

How do you create a text variable?

Use quotes: title = "AMATH 301".

15
New cards

What is a float versus an integer?

Float is decimal-style numeric; int is a whole-number type

16
New cards

What does 5/2 evaluate to in Python 3?

2.5 (division with / gives a floating-point result)

17
New cards

What is the result of 2*(3+4)?

14; parentheses force 3+4 to happen first.

18
New cards

Write the expression 2^5 + 3 in Python

2**5 + 3

19
New cards

How do you calculate tan(e^2) using NumPy?

np.tan(np.exp(2))

20
New cards

How do you calculate a circle's area if radius=r?

area = np.pi r**2

21
New cards

What will print(type(4)) output?

<class 'int'>

22
New cards

What will print(type(4.0)) output?

<class 'float'>

23
New cards

What does # do in a Python line?

Begins a comment; Python ignores the rest of that line

24
New cards

What does x=3; y=x; x=7; print(y) output?

3; assigning a number to y keeps its current value

25
New cards

What does print('A'+'B') output?

AB; the + joins strings

26
New cards

How do you print 'Area: 12' with .format() when a=12?

print('Area: {}'.format(a))

27
New cards

Why does np.pi() cause an error?

np.pi is a numeric constant, not a function; use np.pi.

28
New cards

What happens if you calculate y=x+1 before defining x?

NameError because x does not yet exist.

29
New cards

How do you calculate the square root of 1+8*e?

np.sqrt(1 + 8*np.exp(1))

30
New cards

What does z=3; z=z**2; print(z) output?

9; the second assignment replaces z with its square.

31
New cards
32
New cards

Does np.log calculate log base 10 or natural log?

Natural logarithm, base e

33
New cards

Which arguments does .format() substitute into '{}' placeholders?

Values passed in order: first {} gets the first argument, etc.