Unit 2 Flashcards
is just a file of Python code, which can include
statements, function definitions, and class definitions
module - a script or a short Python program, can be contained in one module
contains the starting point of program
execution
main module
contain function and class definitions
supporting modules
the types of words or symbols used to construct sentences
▪ some basic symbols are keywords, such as if, while, and
def
Lexical Elements
Python keywords and names are _________
case-sensitive - while is a keyword, While is a programmer-defined name
− named locations in computer memory
− languages define rules for naming variables
− should have meaningful names
Variables
In Python, a variable is created when you assign a value to
it. It has no command for declaring a variable.
yeah
A variable can have a short name (like x and y) or a more
descriptive name (age, carname, total_volume).
yeah
Rules for Python variables:
- a variable name must start with a letter or the underscore
character - a variable name cannot start with a number
- a variable name can only contain alpha-numeric characters
and underscores (A-z, 0-9, and _) - variable names are case-sensitive (age, Age and AGE are
three different variables)
nouns or adjectives: denote Boolean values
variable names
- verbs: denote actions
- nouns or adjectives: denote values returned
function and method names
the types of sentences (expressions, statements, definitions,
and other constructs) composed from the lexical elements
Syntactic Elements
indentation and line breaks are ___________ in Python code
significant
Python uses _____________________ to mark the syntax of many types of sentences
white space (spaces, tabs, or line breaks)
Literals
❑Numbers
* integers or floating-point numbers are written as they are in
other programming languages
❑The Boolean values True and False are keywords
❑Some data structures, such as tuples, lists, and dictionaries,
also have literals