String_FunctionsTypes_of_Data_and_Types_of_Errors copy
String_FunctionsTypes_of_Data_and_Types_of_Errors copy
1. Know how to develop text-based programs using string manipulation, including length, upper case,
and lower case.
2. Know how to develop and apply test plans that include normal, extreme and invalid data.
3. Identify test data that covers normal, extreme and invalid.
4. Identify a range of errors, including syntax, logic, and runtime errors.
Know how to develop text-based programs using string manipulation, including length, upper case, and
lower case.
word1 = "programming"
word2 = "MANIPULATION"
Why would you need to find out how many letters were in a word?
Answer: To make sure it was the correct length, to check if a word is entered.
for example:
word1 = "PROGRAMMING"
word2 = "MaNiPuLaTiOn"
word3 = "eNCRYPTION"
word4 = "network"
To output the length of each word in the array. The solution is:
for x in range(0, 4):
print(len(wordArray[x]))
Answer: Find the length of each word and then use an if statement to compare them.
How would you check if the word a user has entered is long enough?
Answer: Find the length of the word and use an if statement to compare it to the minimum length.
Know how to develop and apply test plans that include normal, extreme and invalid data.
Usually before a whole system is tested each sub-system is tested separately. Computer programs can be
tested by running them on a computer using any data that is required and seeing what result is output.
However, in order to test a solution thoroughly it may need to be worked through several times with
different sets of test data. A set of test data is all the items of data required to work through a solution.
Identify a range of errors, including syntax, logic, and runtime errors.
An error just means that a program doesn't work as intended, also called a bug.
Syntax errors
A syntax error means that a program is not valid Python. It doesn't abide by the official rules of the Python
language, just like "eat potato good" does not abide by the official rules of the English language.
Common syntax errors include mismatched parentheses, mismatched string quotation marks, and invalid
indentation.
Runtime errors
he computer only discovers these errors as it's running the program, hence the name RUN-time. The
program is valid Python syntax, but when the computer actually tries to execute a particular instruction, it
gets confused.
With runtime errors, the computer executes all the lines of code before the incorrect line. If these lines
print values, we see their output appear in the console. The computer only reports an error when it
reaches the incorrect line. Then, it terminates the program. It does not execute any remaining lines of
code.
Logic errors
Logic errors are a mismatch between what the programmer intended and what the code they wrote
actually does. To the computer, these programs seem totally fine. There's nothing wrong with the Python
syntax and it understands all of the instructions. When it runs the program, it executes successfully; there
is no error message.
This can make logic errors challenging to spot, because the computer can't offer any help here. The
programmer has to identify why the result they're getting isn't quite right.