Reputation: 269
I have a simple python program:
print 'hi'
Where do I execute this to receive the print statement? Excuse my ignorance, I am just learning python.
Upvotes: 0
Views: 59
Reputation: 8702
Open python IDLE
in windows or just type python
in terminal that
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
C:\Users\Sundar>python
Python 2.7.5 Stackless 3.1b3 060516 (default, May 21 2013, 17:59:42) [MSC v.1500
32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> print 'hi'
hi
>>>
if u type that u get the response.
Adddtionally : there are lot resources and methods
create a file something.py
and in command line u move to loaction where u saved python file and type python something.py
Upvotes: 0
Reputation: 1
I've found the best way for a new user to learn Python is to use IDLE, which comes with the Python installation. Here is a simple and easy explanation on how to get started:
http://www.annedawson.net/Python_Editor_IDLE.htm
Upvotes: 0
Reputation: 5315
Please see this documentation on using the python interpreter: https://docs.python.org/2/tutorial/interpreter.html
python
" into the command prompt.
Doing so will start the python interpreter and will look something like this:
then you just type in your command:
Upvotes: 0
Reputation: 174672
You have a few options:
You can save it in a file. Then run python yourfile.py
to execute the command. The typical file extension for Python source code is .py
.
You can run the Python interpreter. This is a way to quickly test Python code without having to save it to a file. Simply type python
and you will see a few lines telling you the version of your Python interpreter followed by >>>
, which is the interpreter prompt. Any Python statement you type here is immediately executed and the results printed out:
burhan@sandbox:~$ python
Python 2.7.3 (default, Jan 2 2013, 16:53:07)
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> print 'hi'
hi
>>>
To exit the interpreter, type quit()
.
A third way is to use the -c
flag of the Python command. This tells Python to immediately execute the code following the -c
flag, like this:
burhan@sandbox:~$ python -c 'print "hi"'
hi
Upvotes: 2