Computer Science LearnITWithMrC ⛯ Year 7 Year 8 Year 9 GCSE
Responsive image

A Text adventure Part 2

What am I Learning today?

I am learning how to use python to solve complex problems in a modular fashion
I am learning how to use python to create reusable code and import that code into a project

Knowledge Organiser

×

Lesson

Task 0 - Portait images Click to see more

If you don't yet have a portrait image .

Then save one of the images below image into your adventure folder


  • Save your image as character.Gif into your text adventure folder

  • Task 1 - Code so far Click to see more

    Below is the code we have completed so far check yours against the code below and fill in any gaps



    Task 2 - Modular Programming Click to see more

    Chunking your program

    When we are creating a large program it can quickly get very difficult to find things and understand what our program is doing. To make our code easier to read we can split it up into parts and then import those parts into our main program. We do this by using the keyword import and the name of the file we want to include after it. See example below.

    First I create a new file, I want to store my functions in here so I call it 'my_functionsI then create a function to print out the title of my adventure game



    I now create another file main and import my functions sile into it and then call my function that prints out my title.

    I have to use the name of the file the function is stored in and the name of the function when I call it.




    Task 3 - Continuing our Adventure - Asking questions Click to see more

    Have a look at my code below.

    I have saved it as a seperate file called question1.py

    I then import it into the endo of my text adventure file see example below




    My Notes: Text_Programming

    Student_Comment_2 not found

    Task Notes/Comments - Add here Click to see more

    Comments/Notes