Aug 28, 2013

Creating Python programs

Unknown | 2:08 PM |
Welcome to Python!
This post will show you how to start writing programs.
Python programs are nothing more than text files, and they may be edited with a standard text editor Program (Sometimes, Python programs are distributed in compiled form. We won't have to worry about that for quite a while.). What text editor you use will probably depend on your operating system: any text editor can create Python programs. It is easier to use a text editor that includes Python syntax highlighting.

However,

The first program that every programmer writes is called the "Hello, World!" program. This program simply outputs the phrase "Hello, World!" and then ends. Let's write "Hello, World!" in Python.


Open up your text editor (ex: Notepad) and create a new file called hello.py containing just this line (you can copy-paste if you want):

print("Hello, world!")
ordef hello(message):
message = "Hello, world!"print(message)
return message
print(hello("message"))
This program uses the print function, which simply outputs its parameters to the terminal. Print ends with a newline character, which simply moves the cursor to the next line.
Now that you've written your first program, let's run it in Python! This process differs slightly depending on your operating system.

You can also write directly on Python (Python Graphical User Interface). Just open IDLE (Python GUI) and write down:

Print(”Hello, World!”)
And press ‘Enter’ button.
The program should print:
Hello, world! 
Congratulations! You're well on your way to becoming a Python programmer.

No comments:

Post a Comment

Twitter Delicious Facebook Digg Stumbleupon Favorites More

Search