Introducing loops - For
Introducing loops - While
Set your Learning Objectives to red.
We are going to save all of our work for this topic into this PowerPoint.
Save your PowerPoint as 'Programming 1'
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
1. Elephant 2. Impossible 3. This is a sentence
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.
In your Powerpoint put a screenshot of your code.
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.
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