60 likes | 147 Views
Session ObjectivesU2 #S12. Key Words. Pretty Printing. Modal. Dialogue Box. Relational Operators. Arithmetic Operators. Boolean Operators. Arithmetic Operations Continued. Starter: THINK!
E N D
Key Words Pretty Printing Modal Dialogue Box Relational Operators Arithmetic Operators Boolean Operators
Arithmetic Operations Continued Starter: 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.
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.
Determining Character codes As 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( )
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.