Home Accessibility Courses Twitter The Mouth Facebook Resources Site Map About Us Contact
 
For 2023 (and 2024 ...) - we are now fully retired from IT training.
We have made many, many friends over 25 years of teaching about Python, Tcl, Perl, PHP, Lua, Java, C and C++ - and MySQL, Linux and Solaris/SunOS too. Our training notes are now very much out of date, but due to upward compatability most of our examples remain operational and even relevant ad you are welcome to make us if them "as seen" and at your own risk.

Lisa and I (Graham) now live in what was our training centre in Melksham - happy to meet with former delegates here - but do check ahead before coming round. We are far from inactive - rather, enjoying the times that we are retired but still healthy enough in mind and body to be active!

I am also active in many other area and still look after a lot of web sites - you can find an index ((here))
Learning to program - how to jump the first hurdles

From last Sunday ... here are links to the examples of code that I wrote in front of the "Learning to Program in Python" delegates - to show them not only how a program works, but also how I (and other code authors) go from a requirement through to the code that actually does the job. Or, paraphrasing, "a manual is all very well but it doesn't show the process of how the code is developed - you just see the final product, which is of use (but only limited use) if you need to develop code yourself".

Some Early Stuff

Showing operator precedence - how multiplication and division happen before addition and subtraction, but you can alter that using round brackets. [source code]

A first use of conditionals - how you can look at something in your program, and then perform certain tasks based on what you find. This is "if" and "else" (and - depending on the language - elif elsif or elseif). [source code]

And then how you push pieces of code that can be shared between a whole lot of programs out into a separate file that each of those programs can call in. Although you don't think about this naturally when you write your very first programs, you will realise very quickly in your 2nd, 3rd and 4th programs that use the same data that you don't want to recode ... and you don't want to copy and paste either, since you'll end up having to maintain / update multiple copies if you do so. See [source code - calling program] and [source code - shared logic].

The importance of structured or OO programming

I can't stress this enough, even from day 1. You need to write code that will be re-usable and maintainable - a Rembrant and not the dog's dinner.

[here] is a tiny piece of code ... or so it appears at first. In fact, it's a tiny main program that pulls in other bits of code that MIGHT be short or MIGHT be substantial ... but in itself, a very short piece of code to do a job.

That same piece of code is expanded [here] into an example that only runs some of the structured blocks in certain conditions, and is expanded further [here] into code that loops, repeating the operation of one of the structured blocks of code time and time again.

For reference (at this stage), the blocks of code that have the logic hidden within the ("encapsulated") may be found [here].

I have posted further source showing the importance of good variable naming here and of commenting your code here

Looking ahead and motivating the class

Let's face it - you can't learn to program in a day. And a programming language is made up of a large number of different components and concepts which when used together make it powerful. So at the end of the first day's teaching, delegates are seeing something but not the whole picture, and need a beacon to shine ahead and say "this is where we'll be heading by the end of the course in a couple of days".

[here] is an example I wrote at the tail end of Sunday - it's a file parser that went through a log file that's about 30 Mbytes in size and produced me a simple report telling me how many accesses there were in total, and how many to a particular web page. It runs like this:

Dorothy-2:py grahamellis$ python file_first
Whole file was 149307 lines long
Intersting stuff was 11 lines
Dorothy-2:py grahamellis$


You'll spot that a very short piece of code - 21 lines - written at the end of that first day is sufficient to give me a useful analysis of a substantial data flow which wouldn't otherwise have been straightforward. As soon as you have program loops involved, the power of your program increases by an order of magnitude.

It increases by a further order of magnitude when you add in collections - variables that can hold a whole series of values based on a key of some sort; using those, I have been able to expand that previous example to count access to all past blog articles in that log file, rather than just one specific article - so it's a really useful analysis. The sample program, written in front of delegates at the end of the first day to shine a beacon ahead, is [here], and when you run it, it produces a long report ending as follows:

1502 136 Java-sorting-ArrayList-example-generics
255 157 STDIN-STDOUT-STDERR-and-DATA-Perl-file-handles
969 241 Perl-and-
158 937 MySQL-LEFT-JOIN-and-RIGHT-JOIN-INNER-JOIN-and-OUTER-JOIN
Dorothy-2:py grahamellis$


which tells me that the four most popular blog articles (by number of times read) that day were no.s 158, 969, 255 and 1502, that they were read 937, 241, 157 and 136 times ... and that they were about (well - you can see the report for yourselves!).

All of which ain't a bad outcome for new programmers on a Sunday!
(written 2009-08-20, updated 2009-08-23)

 
Associated topics are indexed as below, or enter http://melksh.am/nnnn for individual articles
Y050 - Python - General
  [16] Python training - (2004-08-16)
  [2017] Python - a truly dynamic language - (2009-01-30)
  [2020] Learning Python - many new example programs - (2009-01-31)
  [2227] Learning PHP, Ruby, Lua and Python - upcoming courses - (2009-06-11)
  [2285] Great new diagrams for our notes ... Python releases - (2009-07-13)
  [2394] Two days of demonstration scripts in Python - (2009-09-05)
  [2504] Learning to program in ... - (2009-11-15)
  [2778] Learning to program in Python 2 ... and / or in Python 3 - (2010-05-24)
  [2822] Python training courses for use with ESRI ArcMap software - (2010-06-23)
  [3076] Python through the Snow - (2010-12-01)
  [3463] Busy weekend of contrasts. - (2011-10-03)
  [3489] Python courses and Private courses - gently updating our product to keep it ahead of the game - (2011-10-20)
  [3519] Python - current versions and implementations (CPython, Jython, IronPython etc) - (2011-11-13)
  [3798] When you should use Object Orientation even in a short program - Python example - (2012-07-06)
  [3816] Want to escape the Olympics? Learn to program in the countryside! - (2012-07-23)
  [3902] Shell - Grep - Sed - Awk - Perl - Python - which to use when? - (2012-10-22)
  [3903] Python Programming class for delegates who have already self-taught the basics - (2012-10-25)
  [3911] How well do you know Perl and / or Python? - (2012-11-04)
  [3935] Whether you have programmed before or not, we can teach you Python - (2012-11-25)
  [4236] Using Python to analyse last years forum logs. Good coding practise discussion. - (2014-01-01)
  [4295] A longer Python ... training course - (2014-09-16)
  [4408] Additional Python courses added to our schedule - (2015-01-29)
  [4434] Public training courses - upcoming dates - (2015-02-21)
  [4558] Well House Consultants - Python courses / what's special. - (2015-10-28)
  [4656] Identifying the first and last records in a sequence - (2016-02-26)
  [4712] A reminder of the key issues to consider in moving from Python 2 to Python 3 - (2016-10-30)

G101 - Well House Consultants - Getting to and from Melksham
  [40] Take the train to training - (2004-09-06)
  [154] Railway train service, Melksham station - (2004-12-17)
  [187] a popular bus number - (2005-01-23)
  [413] Save the train - (2005-08-13)
  [486] Rail services under threat - Swindon, Melksham ... and Newquay and Bicester too - (2005-11-05)
  [538] A company we can work with - (2005-12-23)
  [606] Train service from December - (2006-02-14)
  [715] First way to get rid of customers - (2006-05-09)
  [790] Shadow Transport Minister to visit Melksham - (2006-07-02)
  [796] Busy day in Melksham - (2006-07-08)
  [814] Melksham Railway Calendar 2007 - (2006-07-25)
  [856] The train returns for a few weeks - (2006-09-05)
  [952] Coming from London to Melksham by train for a course - (2006-11-28)
  [1085] Lawrence Webb's Melksham Taxi service - (2007-02-18)
  [1428] Travel Across Wiltshire - the game - (2007-11-11)
  [1511] Buses from Well House Manor, Melksham, to Bath - (2008-01-18)
  [1567] Melksham - Swindon. Train v Bus v Car - (2008-03-07)
  [1594] Please support improvements in our train service - (2008-03-28)
  [1723] Bath - Melksham - Devizes. Bus route changes, new timetable - (2008-07-26)
  [1802] Motorcycles welcome at Well House Manor - (2008-09-19)
  [1997] Travelling to a course - station pickups - (2009-01-16)
  [2057] Train and Coach fares from London (and airports) to Melksham - (2009-02-26)
  [2493] Melksham buses to/from Chippenham, Trowbridge, Bath, Devizes, London - (2009-11-05)
  [2634] London to and from Melksham by public transport - (2010-02-13)
  [2789] Melksham to London (Heathrow, and Central London) - (2010-06-02)
  [2791] Bath to Melksham buses - times - (2010-06-03)
  [3276] International travel to the UK - coming to Melksham - (2011-05-03)
  [3751] Public transport for international arrivals into Melksham - (2012-06-04)
  [3752] Melksham Visitors Map - Bus routes and train lines to and from the town - (2012-06-04)
  [4168] Travelling to and from courses - much easier from December 2013 - (2013-09-08)
  [4701] Pretty at the station too - (2016-07-06)


Back to
At the end of the course
Previous and next
or
Horse's mouth home
Forward to
Python - fresh examples of all the fundamentals
Some other Articles
Quiet summer days? I think not!
C++, Python, and other training - do we use an IDE
Using a cache for efficiency. Python and PHP examples
Python - fresh examples of all the fundamentals
Learning to program - how to jump the first hurdles
At the end of the course
Counting Words in Python via the web
Getting it right from the start - new programmers
Alpaca Case or Camel Case
Thornham Farm Shop, Seend Cleeve, nr Melksham
4759 posts, page by page
Link to page ... 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96 at 50 posts per page


This is a page archived from The Horse's Mouth at http://www.wellho.net/horse/ - the diary and writings of Graham Ellis. Every attempt was made to provide current information at the time the page was written, but things do move forward in our business - new software releases, price changes, new techniques. Please check back via our main site for current courses, prices, versions, etc - any mention of a price in "The Horse's Mouth" cannot be taken as an offer to supply at that price.

Link to Ezine home page (for reading).
Link to Blogging home page (to add comments).

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2024: 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho

PAGE: http://www.wellho.info/mouth/2367_Lea ... rdles.html • PAGE BUILT: Sun Oct 11 16:07:41 2020 • BUILD SYSTEM: JelliaJamb