Unit 2 Recitation

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

1/18

encourage image

There's no tags or description

Looks like no tags are added yet.

19 Terms

1
New cards

a name paired with a value

variable

2
New cards

How do we assign a variable a value?

=

  • a = 4, b = 2, c = a * b


3
New cards

Variable Naming Conventions

  • Only contain ______, _____, & ______

  • First letter must be a _____or______


  • letters, numbers, and underscores

  • letter or underscore


4
New cards

Integer

whole number w/o decimal; positive, negative, or 0

5
New cards

Floats

  • number with decimal; positive, negative, or 0.0


6
New cards

Strings

sequence of any characters enclosed in quotation marks; treated like text

7
New cards

Booleans (bool)

True (1) or False (0); used for evaluating statement (is something true or false?)

8
New cards

type()

returns a variable’s data type

Ex: print(type(my_num)) —> <class ‘int’>

9
New cards

Different data types can be interconverted…with some important notes.

  • learn conversion rules b/w data types


Different data types can be interconverted…with some important notes.

  • learn conversion rules b/w data types


10
New cards

Mathematical operators

  • Function:

  • Ex: (7)


  • Function: allow you to carry out math operations

  • Ex: +, -, / (float division), *, ** (exponentiation), // (floor division), % (remainder/modulus),


11
New cards

If one or more numbers in a floor division operation is a float, the operation will return a _____.

float

12
New cards

Self-assignment

When a variable is declared and then reassigned to the variable via a calculation

  • Ex: my_var = 2 / my_var = my_var + 7 (my_var += 7)


13
New cards

Incrementing

Reassigning a variable to itself + 1

Ex: my_var += 1


14
New cards

3 Types of Logical Operators

Relational, Set, Boolean

15
New cards

Relational

checks relationship b/w variables

  • Ex: <, >, ==, <=, >=


16
New cards

Set

checks if a value is in a set

  • Ex: in


17
New cards

Boolean

And, Or, Not

18
New cards

String Comparisons

  • Strings are compared lexographically via ASCII

  • Oder: num < uppercase < lowercase

  • print(“3”<“THREE”<“three”) -> True


19
New cards

Review Truth Tables

Review Truth Tables