8

I am new to Ubuntu. I formerly used to use python on windows, and now I am learning Ubuntu. When I open the command terminal, I type python and press Enter,the symbol (>>>) is shown and I am in IDLE. However, I want to know how I can create functions and classes and the stuff I used to to in Windows.

Thanks.

Jacob Vlijm
  • 85,475

2 Answers2

8

Creating functions using the CLI is very similar to creating functions in scripts. Type your function name and arguments on the first line and append a colon. After that the Pyhton interpreter asks for further input. Now you have to indent the next code you want write in the function body. You finish the function the a blank line.

It should look like:

>>> def fun(a,b):
...     print a,b
... 
>>> 
1

The difference is: in windows you can go to file-->new module and create what you want

I think what you mean is, that in Windows you're used to the IDLE GUI. In Ubuntu you'll have to install the necessary packages in order to run the Tkinter version of IDLE.

Installing the idle Install idle package will make sure you have all the necessary software to run the GUI.

Then run it:

idle

And it's also in your regular applications list.

gertvdijk
  • 69,427