Python basics vocab

0.0(0)
studied byStudied by 4 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/81

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

82 Terms

1
New cards

Expression

a combination of items, like variables, literals, operators, and parentheses

2
New cards

Literal

a fixed value used in code, such as a number, string, or boolean that is directly written in the program

3
New cards

Operator

a symbol that tells the interpreter to perform specific mathematical, logical, or relational operations on operands.

4
New cards

value

a specific piece of data that can be stored in a variable or used in an expression, such as a number, string

5
New cards

float

a data type in Python used to represent real numbers that include a decimal point. It can represent both positive and negative numbers.

6
New cards

integer

a data type in Python used to represent whole numbers, both positive and negative, without any fractional component.

7
New cards

string

a sequence of characters that represents textual data like a person's name, a location, or a message to the user. A string can be created in various ways, such as from user input or from being defined in a program's source code.

8
New cards

evaluates

describes the process of determining the value of an expression or code in Python, executing it to produce a result.

9
New cards

precedence rules

the guidelines that determine the order in which different operations are evaluated in an expression. They dictate which operations take priority over others, affecting how the expression is calculated. These rules influence the outcome of expressions involving multiple operators, ensuring correct and expected calculations.

10
New cards

unary minus

an operator indicating that a number should be treated as negative, effectively changing its sign. In Python, this operator is often applied to numeric types for arithmetic operations. It allows the negation of a value, making it useful for expressions requiring negative numbers.

11
New cards

compound operators

operators that combine an arithmetic operation with assignment, allowing for more concise code. An example is +=, which adds a value to a variable and assigns the result back to that variable.

12
New cards

function

a block of reusable code that performs a specific task. Functions help organize and structure code, allowing for modular programming by enabling the grouping of related operations under a single name and invoking them as needed.

13
New cards

function definition

a description of the input parameters and outputs for a specific function, outlining its purpose and usage within a program.

14
New cards

function call

the action of invoking a defined function in a program by specifying its name and providing the necessary arguments. This executes the code within the function and returns any output.

15
New cards

return statement

a special statement in a function that exits the function and optionally sends a value back to the caller, allowing the function to produce output.

16
New cards

None

a keyword in Python used to exit a function and return a value to the caller, enabling the function to produce output based on its operations.

OR

special keyword that indicates no value

17
New cards

parameter

a function input specified in a function definition

18
New cards

argument

a value provided to a function's parameter during a function call

19
New cards

assignment

the process of assigning a value to a variable in Python, allowing the storage and retrieval of data

20
New cards

prompt

a message displayed to ask the user for input, often used in functions to guide user interaction

21
New cards

interpreter

a program that reads and executes Python code line by line, allowing for immediate feedback and debugging.

22
New cards

code

a common word for the textual representation of a program

23
New cards

variable

a named storage location in memory that can hold different values during program execution, allowing for data manipulation and retrieval.

24
New cards

new line character

a special character used in programming to indicate the end of a line and the start of a new line, typically represented as '\n' in Python.

25
New cards

escape sequence

a series of characters that represent a special character in a string, allowing for formatting and control sequences, such as '\n' for new lines and '\t' for tabs in Python.

26
New cards

whitespace

any character or sequence of characters that represent horizontal or vertical space in text, such as spaces, tabs, and new lines, which can impact the formatting of strings in Python.

27
New cards

type

a classification that defines the nature of data in Python, determining how it can be used, such as integers, strings, lists, and more.

28
New cards

input()

a built-in function in Python that receives input from the user as a string, allowing for interactive user communication during program execution.

29
New cards

syntax error

an error that occurs when the code does not conform to the rules of Python's syntax, preventing the program from executing properly.

30
New cards

logic error

a mistake in a program that produces incorrect or unexpected results due to flaws in the program's logic, rather than a syntax issue. a common type of error that does not stop program execution but leads to incorrect outcomes, often making it harder to identify and fix.

31
New cards

ValueError


An invalid value is used, which can occur if giving letters to int().

32
New cards

TypeError

An operation uses incorrect types, which can occur if adding an integer to a string.

33
New cards

NameError

the program tries to use a variable that does not exist.

34
New cards

IndentionError

Occurs when the indentation of code blocks in Python is inconsistent or incorrect, leading to a syntax issue.

35
New cards

string literal

a string defined in the source code of a program by surrounding the text value with single or double quotes, like 'MARY' or "MARY".

36
New cards

sequence type

a type that orders a collection of objects into a sequence from first to last. A string's characters are ordered from the string's first letter to the last. A character's position in a string is called that character's index.

37
New cards

len()

built-in function can be used to find the length of a string (and any other sequence type like a list).

38
New cards

string concatenation

A program can add new characters to the end of a string in a process known

39
New cards

f-string

allows a programmer to create a string with placeholder expressions that are evaluated as the program executes.

40
New cards

replacement field

placeholder expression. as its value replaces the expression in the final output

41
New cards

format specification

inside a replacement, field allows a value's formatting in the string to be customized

42
New cards

presentation type

part of a format specification that determines how to represent a value in text form, such as an integer (4), a floating point (4.0), a fixed precision decimal (4.000), a percentage (4%), a binary (100), etc. A presentation type can be set in a replacement field by inserting a colon : and providing one of the presentation type characters

43
New cards

Boolean value

a type that has just 2 values, true or false

44
New cards

inequality operator

!=
evaluates if left and right side are inequal or different

45
New cards

equality operator

==
evaluates if left and right side are equal

46
New cards

branch

sequence of statements that only executes under certain condition

47
New cards

if statement

An if statement executes a group of statements if an expression is true. The statements in a branch must be indented, typically four spaces.

48
New cards

if-else statement

An if-else statement executes one group of statements when an expression is true, and another group of statements when the expression is false.

can extend to if-elseif-else

49
New cards

multi-branch if else statements

An if-else statement can be extended to have three (or more) branches. Additional branches use the elif keyword, which means "else if". Each branch's expression is checked in sequence.

As soon as one branch's expression is found to be True, that branch's statement executes (and no subsequent branch is considered). If no expression is True, the else branch executes.

50
New cards

relational operators

checks how one operand's value relates to another, such as being greater than.

51
New cards

operator chaining

For example, a < b < c determines whether b is greater-than a but less-than c. Chaining performs comparisons left to right, evaluating a < b first. If the result is True, then b < c is evaluated next. If the result of the first comparison a < b is False, then there is no need to continue evaluating the rest of the expression. Note that a is not compared to c.

52
New cards

loop

program construct that repeatedly loops the execution of a block of code as long as the expression is true. IF the expression is false, it proceeds past the loop.

53
New cards

iteration

each time through the loop’s statement

54
New cards

while loop

Runs a block of code repeatedly while the condition is true. when the condition is false, the loop ends.

55
New cards

sentinel value

value that cause a loop to end, user controls when the loop ends, distinguishing it from other loops

56
New cards

infinite loop

loop that never stops running because it’s condition is always true

57
New cards

docstring

A special type of comment in Python used to document functions, classes, and modules. It describes their purpose and usage, making code easier to understand.

It is enclosed in triple quotes and can be accessed by the help function.

58
New cards

loop variable

a variable that controls the iteration of a loop, usually updated in each cycle.

can be used for counting

59
New cards

floor division operator

//

A Python operator that divides two numbers and returns the largest integer less than or equal to the result.

60
New cards

modulo

A Python operator that returns the remainder of the division of two numbers.

61
New cards

escape sequence

A special sequence of characters in Python, starting with a backslash (), that allows the inclusion of characters in strings that are otherwise difficult to type or represent such as newlines or tabs.

ex: \n =new line or \t =tab

62
New cards

raw string

A string in Python that treats backslashes as literal characters and does not interpret escape sequences. It is defined by prefixing the string with an 'r'

63
New cards

ord()

A built-in Python function that returns the integer representing the Unicode code point of a given character.

64
New cards

chr()

A built-in Python function that returns the character corresponding to a given integer representing a Unicode code point.

65
New cards

logic operators

are used to combine conditional statements in Python, evaluating to Boolean values.
AND OR NOT

66
New cards

logical AND, logical OR, logical NOT

are operators that combine conditional statements, returning True or False based on the evaluation.

67
New cards

Boolean AND Boolean OR Boolean NOT

are logical operators that evaluate expressions to return Boolean values, aiding in decision-making processes in Python.

68
New cards

conditional expression

is an expression that evaluates to a value based on a condition, typically using the syntax x if condition else y in Python.

69
New cards

ternary expression

is another term for a conditional expression in Python, allowing for inline conditional evaluations with a concise syntax.

70
New cards

container

construct used to group related values together and contains references to other objects instead of data

is a data structure

71
New cards

list

is created by surrounding sequence of variables or literal with brackets [ ], lists are mutable

also a sequence type, meaning contained items are ordered by position in the list, known as list’s index -starting w/ zero

72
New cards

element

a list item

73
New cards

method

instructs an object to perform some action and is specified by providing the object name followed by a "." symbol and then the method name.

74
New cards

append()

list method is used to add new elements to a listat the end of the list.

ex: my_list.append(“abc”)

75
New cards

pop()

list method is used to remove

list.pop(i): Removes the element at index i from list. Ex: my_list.pop(1)

76
New cards

remove()

list method is used to remove the first occurrence of a specified value from the list.

list.remove(v): Removes the first element whose value matches v. Ex: my_list.remove("abc")

77
New cards

sequence-type methods

functions built into the Python language definitions of sequence types like lists and strings. All sequence-type objects have associated methods that typically alter or return some information about the object.

78
New cards

sequence-type functions

functions built into the Python language that take sequences like lists or strings as arguments and operate on the given sequences. They do not require an object or "." dot notation.Ex: len(my_list) retrieves the length of a sequence.These functions operate on sequences without needing to call them on sequence objects.

79
New cards

Tuple

a type of immutable sequence in Python, which can hold a collection of objects. Tuples are defined by enclosing elements in parentheses, allowing for mixed data types and can be indexed.

80
New cards

Named tuple

allows the programmer to define a new simple data type that consists of named attributes. A Car named tuple with fields like Car.price and Car.horsepower would more clearly represent a car object than a list with index positions correlating to some attributes.

81
New cards

set

an unordered collection of unique elements. A set has the following properties:

  • Elements are unordered: Elements in the set do not have a position or index.

  • Elements are unique: No elements in the set share the same value.

Sets can be modified (mutable) with .add(), .pop()-random element, and .remove()-given value, .clear()

82
New cards