Session Objectives #U2S11
-
Upload
oren-william -
Category
Documents
-
view
24 -
download
0
description
Transcript of Session Objectives #U2S11
A Level Computing#BristolMet
Session Objectives#U2S11
MUST identify built-in string manipulation functions
SHOULD correctly use string manipulation functions
COULD combine string manipulation in a working program
Create a password strength indicator program
A Level Computing#BristolMet
String Manipulation - Extraction
Most languages have built-in functions to extract part of a string , often being called LEFT, RIGHT or MID
LEFT (<string>, <number of characters>) i.E LEFT (“Computing”, 3) returns “Com”
but MID (<string>, <starting position>, <number of characters>)
i.e (“Computing”, 4, 3) returns “put”
TASK:Experiment with the string extract functions using Python and then Javascript. Is the syntax and logic the same?
A Level Computing#BristolMet
String Manipulation – Length
Again, ,most languages have a function to calculate the number of characters in a particular string, usually:
LENGHTH (<string>) i.e LENGTH (<“Computing”>) returns 9
TASK: Try this in Python or Javascript.
It is particularly useful validate passwords and increase strengths based on the numbers of characters used.
EXT: Design, create and test a program that will encourage strong passwords to be used. What will you have to do first in order to write a suitable software solution?
A Level Computing#BristolMet
Password Program
Problem analysis:
The program MUST
• Take user input and store as string• Measure length of string• Make decision based on length whether Strong, Medium or
Weak• Output Decision
A Level Computing#BristolMet
String Manipulation - Locate
Another common in-built function is facilitate the ability to search a string for certain sequences of characters.
i.e LOCATE (<search string>, <main string> This varies between languages
LOACTE (“put”, “Computing”) would return 4 as it is found from the 4th character along in the string.
TASK: Attempt in Python or Javascript and test to see working by getting results of 0 and above.
TASK 2: Complete Questions 1-2 in the Activity on p.106
EXT: Create the program in Q3.