Sunday, May 19, 2024
5
rated 0 times [  5] [ 0]  / answers: 1 / hits: 70265  / 1 Year ago, tue, april 4, 2023, 6:06:54

My function sits inside a .py file with the very same name as the function:



emp@emp:~$ python ~/Dropbox/emp/Python/stromkosten_pro_jahr.pyempedokles@empedokles:~$ stromkosten_pro_jahr(20,3)
bash: Syntaxfehler beim unerwarteten Wort »20,3«
emp@emp:~$


Where's the error?


More From » command-line

 Answers
3

You need to cd into the directory where your python file is located and then invoke the python interactive shell to be able to call and run functions interactively.



# cd to the directory
$ cd ~/Dropbox/emp/Python/

# invoke the python interactive shell
$ python # use `python3` to invoke the Python3 shell


The Python interactive shell would look something like:



Python 2.7.6 (default, Mar 22 2014, 22:59:38) 
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>


Here you may import the module (your *.py file) and
run the functions written therein:



>>> from stromkosten_pro_jahr import stromkosten_pro_jahr
>>> stromkosten_pro_jahr(20,3)
[The output of function would be shown right here]


For more information, I would suggest to go through The Python Tutorial.


[#25372] Thursday, April 6, 2023, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
inciplyies

Total Points: 10
Total Questions: 114
Total Answers: 93

Location: French Polynesia
Member since Sun, Dec 20, 2020
3 Years ago
inciplyies questions
Fri, Aug 26, 22, 13:51, 2 Years ago
Sun, Apr 23, 23, 06:51, 1 Year ago
Mon, Sep 13, 21, 03:43, 3 Years ago
;