Chapter 2 Programming

Cards (27)

  • str()
    text called a string
  • int()
    whole number called an integer
  • float()

    decimal number called a float
  • TRUE/FALSE
    Boolean variable
  • ==
    is equal to
  • <=
    is less than or equal to
  • >
    greater than
  • !=
    not equal to
  • Iteration
    a loop,repeat
  • Definite loop
    when you know how many times you want to loop for...
  • Indefinite loop
    when you don't know how many times you want to loop.while...
  • if
    if=selection
  • comments
    explains what each part of the program does;easier to read
  • Descriptive names
    descriptive identifier for variavles/constants/subprograms to make their purpose clear.
  • Indentation
    easier to see where each block of code starts and finishes.Getting this wrong could also reuslt in the program not running.
  • White space
    adding blank lines between bits of code to make them stand out.
  • Strings
    A sequence of characters.They can be letters,numbers,symbols,punctuation or spaces ususally put in speech marks.Substring is a way of extracting part of the string.The substring is also known as a slice.
  • Sub programs
    A piece of code that performs a specific task.
  • Example of sub program
    Turtle is a built in subprogram
  • Recursion
    when subprograms call themselves.You must have a terminating condition otherwise this creates an infinite loop.
  • Functions
    This returns a value to the main program
  • Procedures
    This doesn't return a value to the main program
  • Parameters
    The values that are passed to a subprogram when it is called.
  • Constant
    a set value that can not be changed
  • Local variable
    only accesses from the subprogram in which it is created
  • Global Variable
    can be accessed from anywhere in the program including inside subprograms
  • Scope
    the region of code within a variable is visible(where can that variable be seen-local or global)