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

Super Strings

What am I Learning today?

I am learning how to manipulate string data
I am learning how to find values in a string

Knowledge Organiser

×

Lesson

Task 1 - Getting Organised - PowerPoint Click to see more

  1. Set your Learning Objectives to red.

  2. We are going to save all of our work for this topic into this PowerPoint.

  3. To download the PowerPoint by clicking on the image below


  4. Save your PowerPoint as 'Programming 1'


Task 2 - Strings and sizes Click to see more

Using Strings

A string is any sequence of characters from the keyboard, including digits, letters, and any other characters you can see on your keyboard. It is an important data type/structure used in programming to achieve many different things.


Let's look back at some previous code we used when we were learning how to input data


What we are going to do now is also tell the user how many letters are in their name. To do that we have the use the len() function.

Here is an example



Activity 1

  1. Can you ouput the length of the following strings:
  2. 1. Elephant
    2. Impossible
    3. This is a sentence

  3. Can you add them all together to give the total number of characters used in all three strings?

Extension Activity 1

  1. Get the user to enter a word and tell them how many characters are in the word they enter?

Task 3 - Character Position Click to see more

Wouldn't it be good if we could find out where in the string a character appears. Don’t forget it will start counting from 0.

In this example, it will find the letter "p" in the word "Simple" and display the number of it's position.




Activity 2

  1. Can you find the position of the letter e in the following strings:
  2. 1. Elephant
    2. Impossible
    3. This is a sentence

  3. What happens if you look for a letter that is not in the word?


Extension Activity 2

  1. Create a word and ask the user to guess if a letter is in the word, if it, is output the position of the letter, if it is not say that letter is not in the word. Think of this like the game hangman.


In your Powerpoint put a screenshot of your code.


  • When you are finished don't forget to save your powerpoint

  • Task 4 - Strings are like lists Click to see more

    The reason we have to start counting from 0 when look for the position of a chracter in a string is because strings are like lists.

    The code below shows you that we can output a character in our string just like we did when we outputted an element in our list:


    Notice how we use the index value to access the value in our string just like we did withlists.

    Activity 3

    1. Copy the code below.
    2. Can you ouput just the letter 'e' from each of the variables that are storing the different strings?


    Extension Activity 3

    1. Can you create a hangman game?


    In your Powerpoint put a screenshot of your code.



    Task 5 - Lesson review Click to see more

    Summing it all up

    Lets look at the learning outcomes and decide which one best describes our current level of understanding :

    Tick the one you feel is closest to your level

    Learning Outcomes I need to learn how to manipulate string data

    • I have a basic understanding of how I can manipulate string data with a little help from my teacher
    • I can show my teacher that I can manipulate string data without their help.
    • I can manipulate string data independently and I can also explain it to others and can complete any extension tasks I am given.

    🠜 Now update your learning objectivesClick on the Assessment image

    My Notes: Coding-p2

    Student_Comment_4 not found

    Task Notes/Comments - Add here Click to see more

    Comments/Notes

    Copyright © 2013 - 2024 LearnITwithMrC