Quiz Page python The python quiz has changed! We have replaced python questions with answers! And from those answers you'll find further links to even more information - forums where you can ask questions, training courses, longer articles, and more. [link to quiz index] ...
If you really want the old quiz
questions, you can find them
here,
here,
here and
here ... and
with onward links to the possible answers to each question too.
Python - what is going on around me?If you want to find out what's going on around you in a Python program, you can uses your system's environment variables via the os.environ module - the keys() method telling you which environment ...
Defining a static method - Java, Python and RubyMost methods in classes that your write will be run on / applied to individual objects within that class - you'll be asking for the colour of a marker pen, or setting the price of a hotel room. You ...
Tips for writing a test program (Ruby / Python / Java)Where does my test code go?
If you've written a class - a series of methods to be used within another application - how do you test it? How about writing a test program within the same file which ...
Moving the product forward - ours, and MySQL, Perl, PHP and Python tooI have just posted a "steady as she goes" message, welcoming the new decade but reassuring our customers that we're carrying on offering very much the same high quality courses, and the same high ...
When should I use Java, Perl, PHP, or Python?Java is a good language for bigger systems ... teams of programmers writing bits of code that interact with each other. In fact, Java is so well tuned towards the bigger systems that it's not the ...
Good example of recursion in Python - analyse an RSS feedI'm not keen on recursive code - code that calls itself. Very often, such code is elegant in a way, yet so 'clever' that it is hard to follow. There are, however, exceptions where I say "THAT is a ...
Parallel Pinging, using Python Threads or Expect spawn listsPing is a very useful command to use within scripts for checking the presence (or absence) of a live system on our network, or indeed on the Internet. However, there are subtle differences in the ...
How do I set up a constant in Python?You may think of values like pi being a constant, but in Python they're really just another object that's defined in the namespace of the module from which they're loaded!
So ...
>>> import math
>>> ...
Python - how it saves on compile timePython is interpreted every time you run the code ... or that's the simple first story you're told. But really it's not that simple ... and not that inefficient.
When you run a Python program, it ...
Making executable binaries in Python (or Perl)In a nutshell, translations of any of the scripting / semi-scripting languages into executables require the libraries that are included with the base distribution to be included with them, so they ...
Variable storage - Perl, Tcl and Python comparedFrom Monday to Wednesday, I was teaching Python to a group of delegates at a company where I have previously taught Tcl and Expect and Perl. And this interesting diagram shows just what a contrast ...
Optional parameters to Python functionsPython functions (and methods) can be called with any number (0 or more) parameters, but the calling sequence must match the 'template' or 'function prototype' given when defining the function. ...
Multiple returns from a function in PythonConvention states that you can call a function with many parameters, but you return just one.
There's some truth in that statement, but of course you can often return a collection - an array, list, ...
TypeError: super() argument 1 must be type, not classobj (Python)If you've got an error message like this, you've called up a method from the base class of your object using "new style classes", but the base class is an "old style class". The full error message ...
Robust user input (exception handling) example in PythonOne of the questions in the "exceptions" section of the Python Course asks my delegates to "Graham Proof" a piece of code:
first = int(input("First number: "))
second = int(input("Second number: ")) ...
Testing code in Python - doctest, unittest and othersThe doctest and unittest modules of Python allow you to provide test harnesses for your classes / packages. Designing applications from the bottom up, you'll want to ensure that each of your code ...
Pound Sign in Python ProgramHow do I get a pound sign up in Python? A regular question ans the regular answer is to use a unicode string:
>>> saying = u'It will cost \u00a310.00'
>>> print saying
It will cost £10.00
>>>
...
Two days of demonstration scripts in PythonI've spent the last two days introducing Python to a group of nine delegates (and, naturally, enjoying doing so). As I usually do, I have wrote a lot of new examples to show not only how the language ...
C++, Python, and other training - do we use an IDEA question from my inbox ... "Do you use Visual Studio, or a similar IDE". And worth a full answer, and one to be shared.
An IDE or Integrated Development Environment is a piece of software that ...
Using a cache for efficiency. Python and PHP examplesAsk yourself "how long is it (in seconds) from 5.36 a.m. and 20 seconds to 6.04 a.m. and 39 seconds".
Have you worked that out?
Now - how long is it (in seconds) from 5.36 a.m. and 20 seconds to ...
Python - fresh examples of all the fundamentalsSome more new examples in Python - from this week's course.
From my Introduction to Python / simple example to show the power of the language, I present my example that parsed a big data (log) file ...
Counting Words in Python via the webI love writing things in Python - it's a great language for achieving a great deal in a short time. And it works well got Simple CGI scripts.
Today's challenge - to count the number of words (and ...
Passing multiple results back from a function - Lua, Python, etcHave you ever wondered why you can pass in as many parameters as you like to a function, but only return one? It seems rather unfair, doesn't it - especially as you may have lots of results.
In ...
Great new diagrams for our notes ... Python releasesWhen training, I project onto a white wall ... and I draw onto the projected image, and add extra notes and diagrams around the side too - after all, the whole wall is a whiteboard. Some of the ...
Strings as collections in PythonIn Python, I can treat a string as a collection of characters and iterate through it without the need to do any sort of conversion on it, or muck about with "substr" ...
breakfast = "Croissants and ...
Checking robots.txt from PythonThe robots.txt file - which well behaved automata check to see whether they are welcome on a web site - has two directives in its base specification ' User-Agent and DisAllow. You will find some ...
Python - using exceptions to set a fallbackIn Python, you should use exceptions to catch error conditions such as files that you're unable to open, broken network connections, and user inputs which give a problem - it's all very well putting ...
Creating and iterating through Python listsIn Python, you create lists by putting a series of values in square brackets - and the program creates a list with that number of elements. You can change an element by referring to the element by ...
Python classes / courses - what version do we train on?Usually, the release number of a programming language that's used on a 'first level' course doesn't make a big difference as the changes tend to be quite minor - after all, languages cannot change ...
Is it Python past cheetah already?When my son was young, we had a clock with animals rather than numbers around the dial at each hour, and we used to refer to times like tiger past zebra, rather than twenty past twelve. In retrospect, ...
Handling nasty characters - Perl, PHP, Python, Tcl, LuaAre your writing or maintaining a web based application that uses forms? If so, you have better be aware of some of the nasty characters that are around!
The < character, when echoed back from a ...
Learning PHP, Ruby, Lua and Python - upcoming coursesThe following programming courses are all booking well, but still have good availability:
PHP - starting 6th July
Ruby - starting 14th July
Lua - starting 10th August
Python - starting 17th August ...
Using Python with OpenOfficeThe Python-UNO bridge can be used to call up pieces of Python code from within OpenOffice. The source code of a "hello world" example can be found at ...
Weekday or Weekend PHP, Python and Perl classes?Should we run training courses during the week, or at weekends?
Our 'traditional' business has been 80% + employees of companies, government organisations and educational establishments who have ...
Learning to program in PHP, Python, Java or Lua ...... or in Ruby, Tcl, C, C++ or Perl
Are you new to computer programming? Is it so long since you programmed that you feel very rusty and would like to start again from basics? If you've said "yes" to ...
Learning Python - many new example programsI ran a public Python course earlier this week ... and (as I usually do!) wrote a number of short examples during the class to show the delegates not only how something is done, but also how the ...
UnboundLocalError - Python MessageWhat does THIS mean?
UnboundLocalError: local variable 'taxrate' referenced before assignment
It means that you have tried to modify the value of a variable - perhaps in a function - before you have ...
Python - a truly dynamic languageIn Python everything is an object - and that includes functions which are objects which contain blocks of code. And this means that you can define different functions of the same name depending on a ...
wxPython - Introduction and samplePython has a number of GUIs ... and these days wxPython is the most popular. As one of the latter sessions of yesterday's Python Programming Course, I introduced the GUI and talked a little about how ...
Discount Training Courses - PHP, Perl, PythonHere's an email I wrote in answer to a request for a discount earlier today.
Many training companies quote high(er) prices, with the full anticipation that they can offer a wide range of discounts to ...
|
|