Download Python Programming

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* 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
Codecademy
 Where are you?
 What is your target for this week?
PLENARY
What are the bitwise operators – add one to board
What does each one do?
TOMORROW
Binary, hexadecimal and denary
Conversion between these bases
HOMEWORK
Read and make notes on section 5.1 pages 103 to 108 – answer questions 1 to 5.