Python through command terminal, creating functions?
Solution 1
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
...
>>>
Solution 2
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
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.
Related videos on Youtube
XenonDragon
Updated on September 18, 2022Comments
-
XenonDragon almost 2 years
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.
-
gertvdijk over 10 yearsWhat were you using in Windows as a Python shell? If that's also IDLE, then there's no difference in Ubuntu. However, I think you should check out iPython if you find the time. It's a lot more powerful than IDLE.
-
XenonDragon over 10 yearsThe difference is: in windows you can go to file-->new module and create what you want
-