Survey

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Python syntax and semantics wikipedia , lookup

Python (programming language) wikipedia , lookup

Transcript
```PYTHON PROGRAMMING
Week 14 – Tuesday
STARTER
You need to find out the average of a set of exam marks for a class. You don’t know how many marks there will
be. Each mark is in the range 0 to 100.
Create an algorithm to solve this problem. Show your algorithm using pseudo-code, a structure chart and a flow
chart.
Don’t write the program in Python!!
LAST TERM AND THIS TERM
All the basics for creating Python programs
Tools to help design algorithms to solve problems
This term – see web site.
TODAY
Recap - binary
Bitwise operators in Python
Python practical
RECAP - BINARY
Counting in binary – class discussion
RECAP - OPERATORS
Arithmetic operators:
+, -, *, /, ^^, %
Relational operators:
<, >, <=, >=, ==, !=
Boolean operators:
not, and, or
BITWISE OPERATORS – CLASS RESEARCH AND
EXPLANATION
Research each of these to find out what they do and give an example of each:
<<
- shift bits left
>>
- shift bits right
&
- bitwise and
|
- bitwise or
~
- bitwise not – the ‘complement’
^
- bitwise exclusive or
You will need to explain one of these so make some notes.
EXERCISE
Write down the binary representation of the denary number 19.
 What denary number would you get if you apply the shift operator to shift:








once to the left?
twice to the left?
once to the right?
twice to the right?
What if you and it with 17?
What of you or it with 17?
What is its complement (not)?
What if you xor it with 17?
Check these using IDLE (when completed and shown to me!)
PYTHON PRACTICAL
Complete the bitwise operator exercises