• Shuffle
    Toggle On
    Toggle Off
  • Alphabetize
    Toggle On
    Toggle Off
  • Front First
    Toggle On
    Toggle Off
  • Both Sides
    Toggle On
    Toggle Off
  • Read
    Toggle On
    Toggle Off
Reading...
Front

Card Range To Study

through

image

Play button

image

Play button

image

Progress

1/30

Click to flip

Use LEFT and RIGHT arrow keys to navigate between flashcards;

Use UP and DOWN arrow keys to flip the card;

H to show hint;

A reads text to speech;

30 Cards in this Set

  • Front
  • Back

____ is what we manipulate in Python, like a word or a number. It can be interchanged with ____.

Value/Object

How do you find out which class an object is?

print(type(object))

What's the class of a number with a decimal point?

float

changing a string to an integer, etc, is called

type conversion

names we assign to objects are

variables

what's the general format of an assignment statement

variable name = value

What is this called: =

assignment operator/assignmnet token

In Python, variable names have to begin with either of two types of chracters:

underscore _ or a letter

How do you state this:


n = 17

"n is assigned 17"

Whenever you write a reference diagram or state snapshot or assign a variable, the ____space is on the left and the ___space is on the right.

namespace, valuespace

What is a keyword?

A name that is already assigned to a value in python, so you can't use it as your own variable name

What is a statement?

an instruction the Python interpreter can exucute, such as the assignment statement or an if statement

what's an expression

combination of values, operators, variables, and calls to function. an epression needs to be evaluated. example 1 + 1 or len("string")

what is a function? give examples

examples are print, type, len

what's an operator?

tokens that represent computations such as addition (+)

what is integer division? write a statement using integer division

it truncates the result down to an integer. 5 // 4

What does the modulus operator do?

It divides the first number by the second and returns the remainder ex. 5 % 4 returns 1

x % 10 returns the ____ of x


ex 125 % 10 returns what?

rightmost digit


12

x % 100 returns the _____ of x


ex 125 % 10 returns what?

rightmost two digits


25

5 // 4 returns what?

1

5 / 4 returns what?

1.25

How do you ask a user for input? write a statement asking the user to enter her name.

n = input("Enter your name.")

How do you evaluate this: (2**3**2)

3**2 first (right-most first)

show this in a reference diagram:


bruce = 5
bruce = 7


What is this called?

reassignment


reassignment

x = 5


y = x


x = 7


What is the value of y?

5. y gets assigned the value of x, not x itself. So the value of y doesn't change when x gets reassigned. x = 7 and y = 5.

What is an update? give an example

A type of reassignment where the new value of the variable depends on the old. example x = x + 1

When evaluating a statement, Python evaluates which side first?

the right side

For this update statement


x = x + 1


since Python evaluates the right side of the statement first, you will get an error if you don't do what first? what is the error you will get?

You need to initialize the variable first (assign it a starting value) for ex:


x = 0


NameError: Name 'x' is not defined

updating a variable by adding 1 (ex x = x + 1) is called _____


updating by subtracting 1 (ex x = x - 1) is called ___

increment


decrement

another word for incrementing a variable by 1 is


(ex x = x + 1)

bumping