"Zhuan" Python Beginner Tutorial One — Hello World

The original poster: , cool A Views: 290 Replies: 2 Posted in: 2012-04-18 16:46:04
Document Description: Python Beginner Tutorial One - Hello World

Hello everyone, I think you have been waiting for a long time, but it's okay, because now you can learn Python together with me. (Py is short for Python. Note: the Python here is different from Symbian.) If you still don't know what Py is, quickly check out the Python introduction post; we won't go into it here!

Now let's get to the point and start the tutorial:

1: First, open SL4A
2: Press the menu key —— select Add —— Python 2.6.2
3: We can see two input boxes. The smaller one on top is where you write the name of your program, and the one below is for writing the code.
4: As shown in Figure 1, input:
Top: hello world.py
Bottom: import android
droid = android.Android()
print 'hello world'
5: Menu —— Save & Run. Your first Python program is created, and the result is shown in Figure 2. Isn't it simple?

Now let's analyze the code:
import android means loading the Android module. Besides this, we will later learn about modules like sys, time, etc., but we won't go into them here.
droid = android.Android() can be simply understood as passing the functions of android.Android() to droid, giving droid the functionality of android.Android(), and saving coding effort.
print 'hello world' - print can be considered an output function; whatever you give it, it will output. The content inside the single quotes is what will be printed.

Simple, right? If there's anything unclear, please post a question.

Method for Chinese Output:
It's also simple: just add #coding=utf-8 between import android and droid = android.Android(). Remember this because it does not change.

After learning, let's do an assignment: use print to output 你好世界 (Hello World).

Note: The punctuation used in Python should be typed in English input mode; otherwise, it may cause errors.

End
Visa Information: Not required
📷 picture (2)
picture1
picture2
× Preview
reply 🤍 0 📤 share collect
Indicates that I don't understand what Python means!
Why is there so much of this? It's making my eyes dizzy.
— All replies loaded —

Leave a Reply