Compile Crazy
Would you like to react to this message? Create an account in a few clicks or log in to continue.



 
HomePortalLatest imagesSearchRegisterLog in

 

 Basic Python Scripting

Go down 
4 posters
AuthorMessage
Compu-Teck Inc.




Posts : 80
Join date : 2010-04-29
Age : 31

Basic Python Scripting Empty
PostSubject: Basic Python Scripting   Basic Python Scripting I_icon_minitimeFri Apr 30, 2010 8:51 am

Hello! Many people think programming is difficult, but anyone can do it! For example, in this post is the basic "Hello World!" application for Python, one of the easiest programming languages to use! Mind you, this is just scripting!

Input:
Code:
print 'Hello World!'


Output:
>>>
Hello World!


(Note: If you are using Portable Python [or Python v 3.1 or higher], a version of Python for a flash drive, you will have to input it like this:
print('Hello World!')
Your output will be the same)


Last edited by Compu-Teck Inc. on Thu Aug 26, 2010 8:54 am; edited 1 time in total
Back to top Go down
Excimer Sun Software

Excimer Sun Software


Posts : 152
Join date : 2010-05-07
Age : 31
Location : USA

Basic Python Scripting Empty
PostSubject: correction   Basic Python Scripting I_icon_minitimeFri May 07, 2010 9:05 am

Correction:
For all those using Python 3.0 or lower must input either print('Hello world!') or print("Hello world!"), with the parenthesis. But if you happen to be using Python 3.1 or greater you may use the syntax; print 'Hello world!' or print "Hello world!", without the parenthesis.
Back to top Go down
Compu-Teck Inc.




Posts : 80
Join date : 2010-04-29
Age : 31

Basic Python Scripting Empty
PostSubject: Re: Basic Python Scripting   Basic Python Scripting I_icon_minitimeFri May 07, 2010 9:06 am

Thanks for the correction, Excimer.
Back to top Go down
Excimer Sun Software

Excimer Sun Software


Posts : 152
Join date : 2010-05-07
Age : 31
Location : USA

Basic Python Scripting Empty
PostSubject: self correction   Basic Python Scripting I_icon_minitimeTue Jun 01, 2010 1:44 pm

I am going to have to correct myself Embarassed ! It seems that Python 3.0.x is the only Python version that one must include parenthesis for one's print command with (eg. print("Hello World!")), all other versions of Python appear to allow you to use the print statement without parenthesis (eg. print "Hello World!"). Suspect
Back to top Go down
The Fellow
Admin
The Fellow


Posts : 100
Join date : 2010-04-28
Age : 31
Location : In my head, dreaming up how to shake up the world

Basic Python Scripting Empty
PostSubject: Re: Basic Python Scripting   Basic Python Scripting I_icon_minitimeSun Jun 06, 2010 8:39 am

It allows you to not have to, but alot of the time you can do it if you want.
Back to top Go down
https://compilecrazy.forumotion.net
Excimer Sun Software

Excimer Sun Software


Posts : 152
Join date : 2010-05-07
Age : 31
Location : USA

Basic Python Scripting Empty
PostSubject: re:Basic Python Scripting   Basic Python Scripting I_icon_minitimeMon Jun 07, 2010 9:01 pm

Well...possibly true, but Pyscripter (one of the more recent IDEs for Python, for those who don't know) returns a syntax error upon byte-compiling (for those new to programming, don't worry about that term I just used...yet) the code whenever I leave out the parenthesis in Python 3.0.x. So I would recommend that everyone out there reading this thread and planning on trying their hand at Python 3.0.x play it on the safe side and put in the parenthesis every time when using this Python version. Otherwise don't worry about it because it seems that none of the other versions of Python seem to have even the faintest objection to the programmer leaving the parenthesis out and just using quotes.
Back to top Go down
Compu-Teck Inc.




Posts : 80
Join date : 2010-04-29
Age : 31

Basic Python Scripting Empty
PostSubject: Re: Basic Python Scripting   Basic Python Scripting I_icon_minitimeTue Aug 24, 2010 1:32 pm

Well, as I said in ESS's First C program post, I am going to explain how this program works. Don't worry, it's quite simple! Let's look at the code again:

Input:

Code:
print 'Hello World!'

Output:

>>>
Hello World!


This is one of the simplest codes in Python (and for any other language, but that's beside the point). What happens is by using the "print" command, you are telling Python that what is typed next is to be transferred directly to the output screen. Next, the string (words) "Hello World!" are what you are telling Python to print. NOTE: ANYTHING INSIDE THE QUOTES WILL BE PRINTED!! If you forget the exclamation mark, it will be excluded. Of course, Python will not bother you with grammar, just proper syntax. Well, I hope this makes it easier for anyone who does not quite know how this program works.
Back to top Go down
gamerboy

gamerboy


Posts : 37
Join date : 2010-08-27
Age : 39
Location : Germany

Basic Python Scripting Empty
PostSubject: Re: Basic Python Scripting   Basic Python Scripting I_icon_minitimeFri Aug 27, 2010 5:14 pm

okay, but im assuming (didnt test) that it would show in a console window when opened. what is the command(s) for opening a window? ill guess first, simple guess, but it works on qbasic, so let me try:
Code:
Open Window (x, y)
Back to top Go down
http://gamerboy8864hacks.freeforums.org
Excimer Sun Software

Excimer Sun Software


Posts : 152
Join date : 2010-05-07
Age : 31
Location : USA

Basic Python Scripting Empty
PostSubject: Re: Basic Python Scripting   Basic Python Scripting I_icon_minitimeSat Aug 28, 2010 9:20 am

All you have to do is have Python installed. Once that's done you go to the command line and type 'python', without the quotes, and press enter. This takes you to an interactive Python interpreter, kinda like a command line where, instead of being bash or cmd, the commands are Python. For this tutorial, you would then type in print("Hello World!") or print "Hello World!", depending on your version of Python, and press enter. It should now print 'Hello World!' to the console screen. You can also type this code into a text file, save it with the '.py' extension, then go to the command line, cd (or chdir) to where you saved the .py file and type 'python yourfilenamehere.py' and press enter and that will give the same output.
Back to top Go down
gamerboy

gamerboy


Posts : 37
Join date : 2010-08-27
Age : 39
Location : Germany

Basic Python Scripting Empty
PostSubject: Re: Basic Python Scripting   Basic Python Scripting I_icon_minitimeSun Aug 29, 2010 4:05 pm

i did not mean that. i meant as in:
open a graphical (internet explorer, etc.) window. Not a console window like command prompt.
Back to top Go down
http://gamerboy8864hacks.freeforums.org
Excimer Sun Software

Excimer Sun Software


Posts : 152
Join date : 2010-05-07
Age : 31
Location : USA

Basic Python Scripting Empty
PostSubject: Re: Basic Python Scripting   Basic Python Scripting I_icon_minitimeSun Aug 29, 2010 5:35 pm

Oh, I see. GUI (Graphical User Interface) programming is an entirely different topic. Unfortunately, in Python you can't just create a window like in some languages, you have to write specific code to do it, which varies depending on your program. Otherwise, the only way to run your Python programs is as terminal applications. I'll try to post a Python GUI tutorial once I figure it out myself (I can't seem to get it to work right for some reason.).
Back to top Go down
Compu-Teck Inc.




Posts : 80
Join date : 2010-04-29
Age : 31

Basic Python Scripting Empty
PostSubject: Re: Basic Python Scripting   Basic Python Scripting I_icon_minitimeMon Aug 30, 2010 8:59 am

Yeah, I have been messing with GUI's for about a month and a half and I can't get to work yet either...
Back to top Go down
gamerboy

gamerboy


Posts : 37
Join date : 2010-08-27
Age : 39
Location : Germany

Basic Python Scripting Empty
PostSubject: Re: Basic Python Scripting   Basic Python Scripting I_icon_minitimeMon Aug 30, 2010 9:57 am

you know why? GUI's in python can be hard. (i know from experience) try writing one in LOLCODE or myasshurts programming languages. harder. then try in C, C#, or C++. hard, but errors are diagnosed!
Back to top Go down
http://gamerboy8864hacks.freeforums.org
Excimer Sun Software

Excimer Sun Software


Posts : 152
Join date : 2010-05-07
Age : 31
Location : USA

Basic Python Scripting Empty
PostSubject: Re: Basic Python Scripting   Basic Python Scripting I_icon_minitimeSat Sep 25, 2010 5:29 pm

If you are interested in making Python GUIs, take a look at PAGE. It's a WYSIWYG editor for Python GUIs. It's based on visual Tcl and supports all GUI elements and widgets from the Tkinter and Pyttk GUI APIs.
Back to top Go down
Compu-Teck Inc.




Posts : 80
Join date : 2010-04-29
Age : 31

Basic Python Scripting Empty
PostSubject: Re: Basic Python Scripting   Basic Python Scripting I_icon_minitimeMon Sep 27, 2010 1:20 pm

Do you know any way I could get this?
Back to top Go down
Excimer Sun Software

Excimer Sun Software


Posts : 152
Join date : 2010-05-07
Age : 31
Location : USA

Basic Python Scripting Empty
PostSubject: Re: Basic Python Scripting   Basic Python Scripting I_icon_minitimeTue Oct 05, 2010 8:51 am

Here's its sourceforge page: Linky
Back to top Go down
Compu-Teck Inc.




Posts : 80
Join date : 2010-04-29
Age : 31

Basic Python Scripting Empty
PostSubject: Re: Basic Python Scripting   Basic Python Scripting I_icon_minitimeTue Oct 05, 2010 1:22 pm

Thanks!! pirat
Back to top Go down
Excimer Sun Software

Excimer Sun Software


Posts : 152
Join date : 2010-05-07
Age : 31
Location : USA

Basic Python Scripting Empty
PostSubject: Re: Basic Python Scripting   Basic Python Scripting I_icon_minitimeWed Oct 27, 2010 12:42 am

No problem! Also, another really good one (better, actually) is Glade, which makes use of PyGTK, a wrapper lib for GTK+, a cross-platform graphics/GUI API. Here's its home page: Click me!
Back to top Go down
Compu-Teck Inc.




Posts : 80
Join date : 2010-04-29
Age : 31

Basic Python Scripting Empty
PostSubject: Re: Basic Python Scripting   Basic Python Scripting I_icon_minitimeWed Oct 27, 2010 1:54 pm

I've recently actually started working with a neat little program called Pygame. It basically allows graphics and sounds to be added to games you make in Python. Quite useful, I must say! I will post a link later in the "Tools of the Trade" section...
Back to top Go down
Excimer Sun Software

Excimer Sun Software


Posts : 152
Join date : 2010-05-07
Age : 31
Location : USA

Basic Python Scripting Empty
PostSubject: Re: Basic Python Scripting   Basic Python Scripting I_icon_minitimeWed Oct 27, 2010 9:27 pm

Can it do GUIs, too? I know that it can do 2-D graphics and sound but, otherwise...?
Back to top Go down
Compu-Teck Inc.




Posts : 80
Join date : 2010-04-29
Age : 31

Basic Python Scripting Empty
PostSubject: Re: Basic Python Scripting   Basic Python Scripting I_icon_minitimeFri Nov 05, 2010 10:02 pm

I'm not sure.. I'd have to do some research... but if it does, that would be sweet!
Back to top Go down
The Fellow
Admin
The Fellow


Posts : 100
Join date : 2010-04-28
Age : 31
Location : In my head, dreaming up how to shake up the world

Basic Python Scripting Empty
PostSubject: Re: Basic Python Scripting   Basic Python Scripting I_icon_minitimeSat Nov 06, 2010 5:37 pm

Well, it has features that could make the GUI better I guess, but its focus is in games, which don't have do much gui's. If you wanted to do a GUI in python, might I suggest looking at this list of libraries and what not: http://wiki.python.org/moin/GuiProgramming
Back to top Go down
https://compilecrazy.forumotion.net
Excimer Sun Software

Excimer Sun Software


Posts : 152
Join date : 2010-05-07
Age : 31
Location : USA

Basic Python Scripting Empty
PostSubject: Re: Basic Python Scripting   Basic Python Scripting I_icon_minitimeSun Nov 07, 2010 12:01 am

Soooooo off topic. If we want to discuss GUI stuff (which it seems we do) this content needs to be split off into an appropriate topic under the advanced section for Python.
Back to top Go down
Sponsored content





Basic Python Scripting Empty
PostSubject: Re: Basic Python Scripting   Basic Python Scripting I_icon_minitime

Back to top Go down
 
Basic Python Scripting
Back to top 
Page 1 of 1
 Similar topics
-
» Basic OOP in Python
» Scripting in a Web Page: What is it Good For?
» What is python
» Variables in Python
» Python Import Easter Eggs

Permissions in this forum:You cannot reply to topics in this forum
Compile Crazy :: Programming :: Python :: For Beginners-
Jump to: