Add random values to every height to a given object
The print function will go to the blender console window if you run the code from the text editor (but the code has nothing to print currently. See below). Use the blender Edit menu to Toggle System Console.
You can do what this code is trying to do much more easily with the displacement modifier and a noise texture, or with ANT Landscape addon, which has a readymade tool that uses noise textures to generate random terrain. However, if you really want to do it this way...
The python in this is very broken. I will try to explain.
I am assuming you are running this code in the Blender python terminal, but if you are running it from the text editor, you must add...
import bpy

...at the beginning of the script for it to work.
To otherwise fix the code regardless of text editor or terminal running:
First off, the code passes object1 and height as arguments to the function, but then the function itself creates the variable object1, so that is not needed. Python can create and delete variables on the fly, so there is no need to tell it beforehand &quot;I am going to create these variables here.&quot; The line should be...
def randomheight(height) :

Which gets passed height as a number.
Secondly, the blender API syntax is incorrect in adding n (a number) to vert.co (a 3D vector). Since the up/down axis is Z, which is the third element of the vector, the line should be...
vert.co[2] = vert.co[2] + n

Or you can use...
vert.co[2] += n

To make things more compact.
Thirdly, the code has nothing to print: the randomheight function does not return any value, so python will just print &quot;None.&quot; Also, the code is trying to pass the object name to the function when the function itself looks up whatever the active object is. This should be...
randhomheight(4)

Unless you want to be able to pass the function something so it can work with objects other than the active one, in which case:
You should leave in the object1 argument where you define the function and here where you call it. Then, remove where the function picks the active object and replace it with...
object1 = bpy.data.objects[object1]

...which will look the object up up by the name the function was given.
Sorry about the multiple choice bit at the end, it was just tricky to tell what the code was meant to do.
Hope this helps :-D