This lesson is in the early stages of development (Alpha version)

Python for Absolute Beginners: Glossary

Key Points

Help and Documentation
Data Types
  • There are 4 data types in Python: Integers, floats, strings, and booleans

  • You can use the built-in function type() to find the type of a value

  • Strings are text, they can be added to one another, you can slice them to get a substring, and use the index to acess the individual character

  • Integers are whole numbers. You can use mathemethical operations on them

  • Floats are decimal numbers. You can use mathemathical opreations on them

  • Booleans are either True or False

  • A double equals sign == is used as the equals operator, a single equals sign = is used for variable assignment

Variables and Assignment
  • Use variables to store values.

  • Use meaningful variable names.

  • Python is case-sensitive.

  • Use print() to display values.

  • Variables must be created before they are used.

  • Variables persist between cells.

  • Variables can be used in calculations.

  • Use an index to get a single character from a string.

  • Use a slice to get a substring.

  • Use the built-in function len to find the length of a string.

Data Types and Type Conversion
  • Every value has a type.

  • Use the built-in function type to find the type of a value.

  • Types control what operations can be done on values.

  • Strings can be added and multiplied.

  • Strings have a length (but numbers don’t).

  • Preventing Errors: Handling numbers and strings in Python operations.

  • Integers and floats can be mixed freely in operations.

  • Variables only change value when something is assigned to them.

Built-in Functions and Help
  • Use comments to add documentation to programs.

  • A function may take zero or more arguments.

  • Commonly-used built-in functions include min, max, and round.

  • Functions may only work for certain (combinations of) arguments.

  • Functions may have default values for some arguments.

  • Every function returns something.

  • Use the built-in function help to get help for a function.

  • Python reports a syntax error when it can’t understand the source of a program.

  • Python reports a runtime error when something goes wrong while a program is executing.

Lists
  • A list stores many items in a single structure.

  • Use an item’s index to fetch it from a list.

  • Use slicing to extract part of a list.

  • Lists’ items can be replaced by assigning to them.

  • Appending items to a list lengthens it.

  • Use del to remove items from a list entirely.

  • The empty list contains no items.

  • Lists may contain items of different types.

  • Lists are mutable.

  • Indexing beyond the end of the collection is an error.

For Loops
  • A for loop executes commands once for each value in a collection.

  • The first line of the for loop must end with a colon, and the body must be indented.

  • Indentation is always meaningful in Python.

  • A for loop is made up of a collection, a loop variable, and a body.

  • Loop variables can be called anything (but it is strongly advised to have a meaningful name to the looping variable).

  • The body of a loop can contain many statements.

  • Use range to iterate over a sequence of numbers.

Conditionals
  • Use if statements to control whether or not a block of code is executed.

  • Conditionals are often used inside loops.

  • Use else to execute a block of code when an if condition is not true.

  • Use elif to specify additional tests.

  • Conditions are tested once, in order.

  • A while loop allows you to repeatedly execute a block of code as long as a certain condition is true.

Evaluation

Glossary

FIXME