[Tutor] Running python from windows command prompt

Alan Gauld alan.gauld at btinternet.com
Wed Apr 10 19:26:29 CEST 2013


On 10/04/13 13:32, Arijit Ukil wrote:
> I like to run a python program "my_python.py" from windows command
> prompt. This program ( a function called testing) takes input as block
> data (say data = [1,2,3,4] and outputs processed single data.
>

Hopefully the code below is not your entire program. If it is it won't 
work. You define 2 functions but never call them.

Also you don't print anything so there is no visible output.
Finally this a code does not read the values from sys.argv.
(See my tutorial topic 'Talking to the user')

As for the error message, others have replied but basically you need
to either change to the folder that your file exists in or specify
the full path at the command prompt.

> import math
>
> def avrg(data):
>     return sum(data)/len(data)
>
> def testing (data):
>     val = avrg(data)
>     out = pow(val,2)
>     return out

HTH
-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/



More information about the Tutor mailing list