chapter 4 : programming

Cards (28)

  • to vary what a program does you use a conditional structure
  • conditional structure is also called an ‘if’ structure
  • in a conditional structure, it starts with the word ‘if’ and then has a logical test
  • the logical test can be true or false
  • a logical test uses operators to compare values
  • a logical test usually compares two values 

    it uses relational operator to compare the two values
  • relational operators are used to compare numbers
  • operators and what it means
    == equal to
    != not equal to
    > greater than
    < less than
    >= greater than or equal to
    <= less than or equal to
  • The word ‘if’ is a python key word
  • in most programming languages, every loop has an exit condition
  • the exit condition is how you stop the loop
  • there are two types of loops:
    • a counter loop (or fix loop) repeats a set, number of times and stops
    • a conditional loop (or condition control loop) is controlled by a logical test
  • a counter loop is called a for loop
  • another name for counter loop is fixed loop because the commands inside the counter loop repeat a fixed number of times. you set the number of repeats on the top of the loop.
  • conditional loop:
    the loop will repeat until the condition is true: this is in scratch
    • if the condition is false, the loop will continue
    • if the condition is true, the loop will stop
  • use a loop when you want to repeat commands inside a program
  • if you know exactly how many times do you want to repeat the commands, use a counter loop
  • If you don’t know exactly how many times you want to repeat the command, use a conditional loop
  • in python a conditional loop is called a while loop
  • conditional loop:
    the loop will repeat until the condition is true: this is in python
    • if the condition is false, the loop will stop
    • if the condition is true, the loop will countinue
  • the rules of a programming language are called syntax
    if you break the rules of a programming language, you make a syntax error
  • translating : the computer turns the commands into machine code

    running : the computer executes the machine code commands
  • Program commands the handle inputs and outputs are called interface
  • comment explains what each section of the program is designed to do
  • The rules of the language, such as the rules of a programming language is known as syntax
  • The counter looping statement repeats a set number of times then stops
  • the program is readable if it is easy to understand
  • a syntax error is a type of error that breaks the rules of a programming language