Arithmetic Expressions Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

What algebraic rules does Python adhere to?

A

PEMDAS

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What happens when you mix an integer and floating-point value in an arithmetic expression?

A

results in a floating-point value

ex. 7+4.0
–> 11.0

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What happens when you mix strings with integers or floating point values?

A

error

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

how are powers shown?

A

**

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is floor division? What is its operator?

A

//
divides but drops the fractional part:
ex. 7//4 = 1 (drops 0.75)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How can you calculate a remainder? What is its operator?

A

%
ex. remainder = 7%4
–> 3

aka modulo divide/modulus

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is a function?

A

a collection of programming instructions that carry out a particular task

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What are built-in functions?

A

small set of functions that are defined as a part of the python language

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What are examples of built-in functions?

A

abs(x)
round(x)
max(x1,x2,…,xn)
min(x1,x2,…xn)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is a library?

A

collection of code written and compiled by someone else that is ready for you to use in your program

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is a standard library?

A

a library that is considered part of the language and use be included with any Python system

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

how is python’s standard library organized?

A

with modules – related functions and data types are grouped in the same module

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What must be done before using functions in a program?

A

functions defined in a module must be explicitly loaded into the program

ex.
from math import sqrt
y = sqrt(x)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

how do you import a function from a module?

A

from (module) import (function)
from (module) import * (imports all functions)
import (module) (imports all functions)
–> must include module.function

ex. import math
y=math.sqrt(x)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What are the rules of parentheses?

A

at ANY POINT in an expression “(“ ≥ “)”
at the END of the expression “(“ = “)”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly