Download - Session ObjectivesU2 #S12
A Level Computing#BristolMet
Session ObjectivesU2#S12
MUST describe the terms modal and pretty printing in term of input and output facilities.
SHOULD explain the use of character codes when comparing string variables (strings)
COULD create string based algorithms using a high level programming language
A Level Computing#BristolMet
Key Words
Dialogue Box
Boolean Operators
Arithmetic Operators
Pretty Printing Modal
Relational Operators
A Level Computing#BristolMet
Arithmetic Operations ContinuedStarter: THINK!Which of the 4 arithmetic operations (+, -, *, /) needs to be handled differently by a programme and why?
Copy down the table for these operations on p.101
Also, make sure you have the relational (or comparison operators) noted down as you will also need them later on.
Test whether the syntax you have works using the Python Shell, if not find the correct syntax and share.
A Level Computing#BristolMet
Input and Output facilities
All systems have methods for input and output. How this is done depends on the type of interface (GUI, menu or command based)And the hardware available (input/output devices).
Today will be mainly using the Python Shell directly which is both the input and output facility but what type of interface would you describe it as?
Jargon:Modal – the dialogue boxes we have been using in Javascript are known to be modal, as the user cannot continue until the box has been closed. Sound familiar?
Pretty Printing – Many languages offer the facilities to display lines of test neatly, with specfic formatting such alignment etc. This is useful when outputting to text files or a printer.
A Level Computing#BristolMet
Determining Character codesAs we know every character has its own value or binary bit pattern. The ASCII conversion system is commonly used. In most languages the ASCII value of a character can be determined using:ASCII (“character”)
Likewise, a character can be determined by its code value using:CHAR (“character code”)
Use the Python Shell to see if these built-in functions work, if not, find ones which do.
Experiment with different characters and think why might this be useful when comparing strings?What problems might occur and what methods could be used by a programmer to overcome these problems?
ord (“ “)
chr ( )
A Level Computing#BristolMet
Test your knowledge
TASK 1: Let’s test your understanding of string manipulation by completing the Exam Question 1 c- g Jan 2013
TASK 2: Activity Q 1 on p.106
TASK 3: Now attempt the practical Qs 2 and 3 on p. 106.