Exercise or example to reinforce idea of functions? I have a group of students with a very shaky understanding of functions and their purpose (encapsulation, reuse, modularization). The assignments I give them require them to write simple functions that return boolean T/F, an integer or a simple Python object (str, list, etc.), then have the caller use the returned value in a print statement. Their programs are written in Python and run from the Windows command line.
The problem is that from the command line, the programs work but if you look inside it's a mess. The functions ignore the parameters to reach into the main for global variables (misunderstand the idea of parameter passing), the input validity checking is done in the caller (defeating the idea of encapsulation, e.g is day of month valid for a given month), or the function prints the result without returning anything. The worst that I get is the function does all the work of the main and of the function, for example when asking for a simple function to add 1 to its argument, I get:

def add1(x):
    myval = int(input("Number?"))
    print(myval+1)

add1(x)


...which of course is nonsense.

Here's my question... Can I craft an exercise that calls a simple function like add1() that would give a dramatically wrong output, e.g. cause the screen to "blow" up if the function printed instead of returned, or stalled if it kept asking for input. I'm thinking of something that reads a large file of text or numbers.

The students are at the community college level and are not programmers -- they are in electronics technology (and some are convinced that there is no software involved in electronics). I use Python but this is (mostly) language independent (I see the same shaky understanding with C++ functions in the Arduino world in another course).

Thanks in advance
 --Louis
I saw the light at the end of the fiber optic cable as soon as you said that these are students of electronics. There is nothing more modular and encapsulated than that! Software is simply electronics without the hardware part. 

If you said to them, "What are the building blocks of a simple AM radio receiver?" they would (hopefully) reply something like: antenna, tuning, rectification, filter, audio output... A crystal radio has all of those. They already know that it is pointless to build the antenna in to the filter, or duplicate the tuning parts more than once. They know that they can work in teams to produce parts that fit together to make a complete radio.

So speak to them in a language they already know: the functional relationship of parts and wholes. Using globals instead of parameters would be like having extra cables going outside the radio to connect different parts of it to the signal path or the power supply. Can you say "Rube Goldberg"? I knew you could. 

Man, let me teach them. I have been studying electronics on my own since before anyone I knew even had seen a computer. Electronics students should be the easiest audience in the world to teach programming to. Use examples they already know.