MACS 401 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/19

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 5:20 PM on 10/7/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai
Chat

No analytics yet

Send a link to your students to track their progress

20 Terms

1
New cards

Namespace

a collection of names and their associated objects or mapping between variable names and python object (like a dictionary)

  • can change depending on where you are in your program

  • can store names of variables, functions and classes

  • currently defined symbolic names and information about an object


2
New cards

Variable

pointers that "point" to objects.

  • flag or name of an area of memory (‘object’)


3
New cards

Class

like an object constructor, or a "blueprint" for creating objects

  • Objects have different attributes and respond in different ways to built-in functions

  • Can be used to store information

  • Certain names or identifiers can never be used (False, else, if, etc… has its own meaning)


4
New cards

Data Types/Classes

  • float - a real number w/ a fractional part

  • int - used for integers.

  • str - used for texts. We can define strings using single, double, or triple quotes. They’re also used for writing function documentation.

  • bool - used for truth/false values. Useful to perform a filtering operation on a data.

  • list - used to store a collection of values.

  • dict - used to store a key-values pairs.

  • complex - complex number such as 5i


5
New cards

List

an ordered, changeable sequence or data structure. Use when order matters and you'll add, remove, or reorder items.

  • numbers = [1, 2, 3]

  • Lists are not meant for math! They don’t have a datatype.


6
New cards

Tuple

an ordered sequence that can't be changed after creation. Good for fixed groupings like coordinates

  • raw_data = (1, 2, 3)

  • point(3, 4)


7
New cards

Index

the numerical position of an item within an ordered sequence, such as a list, string, tuple, or range

  • my_list[0][1] with the “0” being the item in the list and the “1” being the position of the letter/number in the item

  • negative indexing exists, with -1 referring to the last letter/number in a term

  • python counts from ZERO


8
New cards

Inclusivity

Python is left-inclusive and right-exclusive when using ranges and slicing.

How It Works

• Left side (Start): Included in the result.

• Right side (Stop): Excluded from the result.


9
New cards

Conditionals

if and while statements

  • also elif, else, for


10
New cards

Comparison Operators

a symbol that allows you to compare two values and return a Boolean result: either True or False

== equal to

!= not equal to

< less than

> greater than

>= greater than or equal to

<= less than or equal to

and

or

11
New cards

Loop

programming construct that allows a block of code to be executed repeatedly until a certain condition is met

  • Iterates over any iterable — list, string, range, tuple, dict, file, etc.

  • range(n) generates numbers 0 to n−1

  • for i in range (5) = 0, 1, 2, 3, 4

  • break exits early, continue skips to the next item


12
New cards

Functions

a piece of reusable code solving a specific task

  • can create functions using: def function_name()

  • can be created or built in already to python

  • take some inputs (“arguments”) and do something in response


13
New cards

Methods

function that is available for a given object depending on the object’s type.

14
New cards

Data Structures

a way of organizing and storing data so you can access and change it efficiently, may have specific operators that work on them.

  • ex) Int, Float, Str, Lists, Tuples


15
New cards

Boolean Logic

a form of algebra where all variables and values are strictly limited to one of two states: true (1) or false (0)

16
New cards

Dictionaries

maps keys to values, unordered

  • d = {‘name’: ‘Ryan’, ‘number’: 2}

  • d = dict(name='Takaya', age=25)

  • to access a value type: d['name']


17
New cards

Pure function

Functions that don’t modify their arguments or produce any other side-effects

18
New cards

Impure function

Functions that modify their arguments or cause other actions to occur

19
New cards

Magic/dunder method

special methods that begin with double-underscores, which allow us to customize the behavior of our classes.


20
New cards

Slicing

  • The first character has index 0

  • Slice To the End: print(b[2:])

    • Get the characters from position 2, and all the way to the end

  • Slice From the Start: print(b[:5])

    • Get the characters from the start to position 5 (not included)