• Data the kinds of info we want to move around

    • numbers

      • Integers

        • x = 5

      • Floating-point numbers (Float)

        • y = 3.14

    • strings

      • name = "Alice"

    • boolean

      • is_ready = True

        finished = False

    • Primitive: Integer, float, boolean, None, and string are primitive data types because they represent a single value.

    • Containers: Other data types like list, tuple, and dictionary are often called data structures or containers because they hold multiple pieces of data together.

  • Operations

    • Addition: +

    • Subtraction: -

    • Multiplication: *

    • Division: /

    • Integer Division: //

    • Modulus (remainder): %

    • doesn't work on boolean

  • Boolean Operations

    Used with True and False.

    • and – True if both sides are True

    • or – True if at least one side is True

    • not – reverses True/False

    • x = True

      y = False

      print(x and y) # False

      print(x or y) # True

  • commands

    • assignment -bind name to value

    • input and output

      • print

    • conditionals

      • branches

      • changing the flow of control through the sequence of instructions

    • loop mechanisms

      • while

  • Good Style

    • things you aught to do

    • use comments to highlight what you're doing int he code to debug

    • type discipline

    • the types of operands before you apply operators what the code is expecting

    • good variable names

    • testing all possible branches through a piece of code with the conditions, that all possible inputs give you the expected outputs

  • Common code to address types of problems

  • Iterative Programs

    • choose the variable that will count(generically) could be collective data, the mechanisms will determine the variables

    • need to initialize the counter

    • the initialization occurs outside oft he loop, where to start.

    • setup the right end testing - how do I know when Im' done with the loop

    • Includes the variable(the thing that is changing)

    • Construct the block of code

      • set of instructions

      • same set of instructions inside of the loo

      • it will change the data structure

      • inside of here change the variable, if the variable is not counting you have an infinite loop

      • what do I do when I'm done.

    • count = 1 # initialization (outside loop)

      while count <= 5: # end test (condition)

      print(count)

      count = count + 1 # update variable

  • Structure of problem mapping to an iterative problem

    • what are the steps through the problem

    • start at 1

    • then x^2 and find the eventual solution where the square is equal to x

    • some variable counts

    • the end test

    • keep changing the variable

    • and to finish write the end statement

    • logical flow chart of start ans =0 in rectangle to diamond shape for processing, to 'y' back to loop start with condition at the bottom 'n' box print, logic, stop.

  • box with start > diamond take x, integer division by 2 multiply by 2 and check to see if that is the same as x, if answer yes, then print 'even' if 'no' print odd

    • there are different kinds of complexity

    • simple branching programs the amount of time it takes to run

    • is bound by the instructions

    • it does not depend on the size of the input

    • the logical paths are clear

    • each box gets touched once

  • A linear process

    • the number of times go around the loop, are directly related to the size of the argument

    • if increase by 5 then increase the arguments 5 times