9_3_4

WHAT: Use, understand and know how the following statement types can be combined in programs: variable declaration, constant declaration, assignment, iteration, selection, subroutine (procedure/function)

HOW:

Activity 1 - READ

A re-cap of terminology:

  • variable declaration - storing data that will change whilst the code is running. The convention for this is to start with a lower case letter with the second, third or fourth words capitalised at the initial. e.g. myNewVariable
  • constant declaration - storing data that won't change whilst the code is running. The convention for this is all upper case. e.g. MYCONSTANT
  • initialisation - putting a value into a variable for the first time
  • assignment - putting a value into a variable
  • iteration - loop or repeat
  • subroutine - store some code for me to use later on, as many times as I need
  • function - a subroutine that returns a value
  • procedure - a subroutine that doesn't return a value

Activity 2

Hashtag it out!

Copy and paste the code below into Python and use #hashtags to show where each of the keywords above are in the code. Two have been completed for you.

def multiply(x):
    return (x*5)
def chosen(option):
    if option == 1:
        GAME = "A list of numbers"
        print (GAME)
        for x in range(0,10):
            print (x)
        print (multiply(x))
        menu()
    else:
        quit()
    
def menu():
    
    print ("This is the menu")
    print ("----------------")
    print ("Choose from:")
    print ("1. Play")
    print ("2. Quit")
    option = int(input()) # variable declaration and initialisation
    while option not in [1,2]:
        print ("You must type 1 or 2")
        option = input() # variable assignment
    chosen(option)
menu()    

CHECK:

EMBED:

  1. Find three applications that you have already made in Python.
  2. Make sure that they work.
  3. Open a new Python file.
  4. Create a menu system.
  5. Copy and paste the code for each of the three applications into the new Python file.
  6. Use the menu system to allow a user to choose which application they would like to run.

Basically...put three of your applications into one file and make them accessible via a menu system

CLASSROOM IDEAS:

When you teach, make sure that you use the correct terminology for the aspects of programming. This will help to "drip feed" the correct words to the students.