PYTHON DEFINITIONS Flashcards

1
Q

Primitives

A

o Numbers
o Strings
o Booleans

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

Numbers

A

values that allow us to do calculations and keep count.

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

Strings

A

Are any sequence of characters (letters, spaces, numbers, or symbols). used to represent text or speech.

“Hello World”

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

Boolean

A

represent one of two values, true and false.

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

Operators

A

Are different symbols that represent an operation, such as the plus sign (+) as a symbol for addition.

Operations enable us to process our data, to transform it into something else.

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

Operating in Program include

A

*Making calculations using arithmetic operators.

*Comparing information using comparison operators.

*Creating logical expressions using logical (aka Boolean) operators.

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

Arithmetic Operators

A

Performs Calculations

+, -, *, /

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

Comparison Operators

A

Comparing values and evaluate their relationship

Less than < — value to the left is less than the value to the right: 2 < 6

Greater than > — value to the left is more than the value to the right: 14 > 5

Equals == — value

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

Tuple

A

is an ordered sequence of objects or characters separated by commas with parentheses on either side of the sequence.

mytuple= (7,”u”,”p”,1,”e”)

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

Strings & Tuple

A

Both immutable / you can’t update the data once you create it.

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

Variable

A

Stores your data information

mycoffee:

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

Dictionaries

A

Stores data as a collections of key-value pairs.

menu= {“avocado toast”: 6, “carrot juice”:5, “blueberry muffin”]

menu = dictionary
avocado toast , 6 = key-value pair (comparing both vaules)

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

Interger

A

Whole number without decimals

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

Control Flow

A

Control flow is the order in which instructions are executed.

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

List

A

Used to store multiple items in a single variable.

[2,4,6,8,10,12]

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

Logical /Boolean Operators

A

*AND — both expressions evaluate to true, so the final result is true:
o ((4 > 1) AND (2 < 7)) is the same as (TRUE AND TRUE).

AND/ OR / NOT

17
Q

Float

A

Numbers with decimals

18
Q

Arrays

A

Is a variable that can store more than one method at a time.

It is used to store a collection of data.

EXAMPLE:

Variable = A
Value = 1-100

A (0), A (1), A (2), A (3)

Example:
append() = add an element at the end of the list
clear() = remove all copy
copy()= return all copies to a list

array (‘i’, [1,2,3,4,5,])
for numbers in numbers:
print(numbers)

NOTE: indexing values start from 0 and then 1

19
Q

Index

A

The INDEX function returns a value or the reference to a value from within a table or range.
()

20
Q

Advantages of an Array

A

Save memory in your system.

Array’s don’t slow down your memory or cache because the system recognize it as one big function rather than an individual “list” or “table.”

Arrays value are near each other in memory. It’s easy to transfer from Cache to CPU.

21
Q

Loops

A

A segment of code that executes multiple times.

22
Q

Iteration

A

the process in which the code is executed once.

Used in Loops

EXAMPLE:

numbers = [0, 254, 2, -1, 3]

for num in numbers:
if (num < 0):
print(“Negative number detected!”)
break
print(num)

OUTPUT:
0
254
2
Negative number detected!

23
Q

Function

A

A function is a block of code which only runs when it is called.

A function is a named sequence of instructions, packaged as a unit, that performs a specific task.

24
Q

Parameters

A

Parameters are variables that are defined in the function definition.

Example:

def_godfathermovie (cinematic, suspenseful, violent).

25
Q

Conditional Control

A

Allows the program to do different things in different scenarios.

Example:
If set to X, then do step 1, other wise do set 2.

26
Q

Three Major Control Structures

A

Conditional: “if some condition is met, then do X. Otherwise, do Y”.

Loop: “do something Z number of times” or “do something repeatedly until some condition is met”.

Exception: “do steps A, B, C. If an error occurs, stop, and do steps J, K, L”.

27
Q

Appending

A

When you add something to the end of a list.

Example:

my list - [“Nas”, “Jay” , “Pac”, “Biggie”]

mylist.append(“Eminem”)

my list - [“Nas”, “Jay” , “Pac”, “Biggie”,”Eminem]

28
Q

Pop

A

Removes Items from your list

Example:

my list - [“Nas”, “Jay” , “Pac”, “Biggie”]

mylist.pop(“Biggie”)

29
Q

Splice

A

Use an index to select a remove a specific item out of the list.

Example:

my list - [“Nas”, “Jay” , “Pac”, “Biggie”]

mylist.splice(1)

my list - my list - [“Nas”, “Pac”, “Biggie”]

30
Q

For Loop (Count Control Loop)

A

Executes a set of instructions for a specified number of times.

For Loop - is good when you know the number of times you are trying to run your variable.

31
Q

While Loop (Condition Control Loop)

A

When you know when a program should stop, but not the number of times it should repeat.

It repeats a set of instructions while that condition is true.

32
Q

For Each Loop (Collection-Controlled loops)

A

Repeat for each item in a collection

33
Q

Inifiite Loop

A

is a loop that never terminates.

Infinite loops result when the conditions of the loop prevent it from terminating

34
Q

Iteration

A

Repetitive execution of the same block of code over and over

35
Q

Indefinite iteration

A

Where the number of times the loop is executed depends on how many times a condition is met.

36
Q

Definite iteration

A

where the number of times the loop will be executed is defined in advance (usually based on the collection size).