![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Hobbyist Programmer
|
New Proggie Language!!YAY!
Well I have decided to learn Python. Does anyone know how to do hello world?!
__________________
And there was much rejoicing... Yay.... |
|
|
|
|
|
#2 |
|
Programmer
Join Date: Feb 2005
Posts: 67
Rep Power: 4
![]() |
I take it, that you already have the python compiler:
print 'Hello World' ![]() |
|
|
|
|
|
#3 |
|
Professional Programmer
Join Date: Feb 2005
Posts: 434
Rep Power: 4
![]() |
A little more advanced:
# this will print Hello World! 10 times for q in range(10): print "Hello World!" # this will spell it out for you for c in "Hello World!": print c # this will spell it out for you with sound effect import winsound for c in "Hello World!": print c winsound.Beep(800,100)
__________________
I looked it up on the Intergnats! Last edited by Dietrich; Mar 5th, 2005 at 9:22 PM. |
|
|
|
|
|
#4 |
|
Programmer
Join Date: Feb 2005
Posts: 67
Rep Power: 4
![]() |
Show off!
Just to make me feel stupid.. ![]() |
|
|
|
|
|
#5 |
|
Expert Programmer
|
I prefer to to make it say it ten times like so
x = 0
while x < 10:
print "Hello, World."
x = x + 1 |
|
|
|
|
|
#6 | |
|
Professional Programmer
Join Date: Feb 2005
Posts: 434
Rep Power: 4
![]() |
Quote:
__________________
I looked it up on the Intergnats! |
|
|
|
|
|
|
#7 |
|
Programmer
Join Date: Feb 2005
Posts: 67
Rep Power: 4
![]() |
I was jsut kidding with you...
Hope you did not take offense!? |
|
|
|
|
|
#8 |
|
Newbie
Join Date: Feb 2005
Posts: 8
Rep Power: 0
![]() |
If you really wanted to make "Hello, world!" difficult for yourself, you could do:
import sys
sys.stdout.write("Hello, world!\n") |
|
|
|
|
|
#9 |
|
Programmer
Join Date: Feb 2005
Posts: 67
Rep Power: 4
![]() |
Good thought...
What is actually the point of this complicated syntax for the 'print' statement? Has it any special powers, that justify it's existens, or has it survived out of an older version of python? --> somewhat off topic, but it just interested me. |
|
|
|
|
|
#10 |
|
Professional Programmer
Join Date: Feb 2005
Posts: 434
Rep Power: 4
![]() |
If you have wxPython v2.5 installed, you can really show it off!
# Hello World using Python 2.3 and wxPython 2.5
import wx
def create(parent):
return Frame1(parent)
[wxID_FRAME1, wxID_FRAME1STATICTEXT1] = [wx.NewId() for _init_ctrls in range(2)]
class Frame1(wx.Frame):
def _init_ctrls(self, prnt):
wx.Frame.__init__(self, id=wxID_FRAME1, name='', parent=prnt,
pos=wx.Point(326, 167), size=wx.Size(523, 173),
style=wx.DEFAULT_FRAME_STYLE, title='Show it off!')
self.SetClientSize(wx.Size(515, 133))
self.staticText1 = wx.StaticText(id=wxID_FRAME1STATICTEXT1,
label=' Hallo World!', name='staticText1', parent=self,
pos=wx.Point(0, 0), size=wx.Size(515, 133), style=0)
self.staticText1.SetFont(wx.Font(48, wx.SWISS, wx.NORMAL, wx.NORMAL,
False, 'Comic Sans MS'))
self.staticText1.SetForegroundColour(wx.Colour(255, 255, 0))
self.staticText1.SetBackgroundColour(wx.Colour(0, 128, 64))
def __init__(self, parent):
self._init_ctrls(parent)
if __name__ == '__main__':
app = wx.PySimpleApp()
wx.InitAllImageHandlers()
frame = create(None)
frame.Show()
app.MainLoop()Actually I cheated a little, and used the Boa Constructor visual IDE. I only entered "Hello World!" and set the font and colors, clicking on the right places. Oh Gee! I am not a show-off after all!
__________________
I looked it up on the Intergnats! |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|