The beginning of python---hello world!

Source: Internet
Author: User

(1) Frontier

(2) Introduction to Python

(3) Python Hello World implementation

(4)

-------------qq:1327706646

--------------------------------Author:midu

-----------------------------------------------datetime:2014-12-12 14:25:00

(1) Frontier

In order to contact Python, basically see a variety of image algorithms appear, let me have curiosity, the reason why today to knock this code, is a bit of time, Python is a scripting language, so I think the introduction is relatively simple, very shell a model, including running mode.

(2) Introduction to Python

To complete the same task, C language to write 1000 lines of code, Java only need to write 100 lines, and Python may be as long as 20 lines. So Python is a fairly advanced language. You may ask, is the code less good? The cost of the code is slow, the C program runs for 1 seconds, the Java program may take 2 seconds, and the Python program may take 10 seconds. Is that the lower the more difficult the program, the more advanced the simpler the program? On the surface, yes, however, in very high abstract calculations, advanced Python programming is also very difficult to learn, so the Advanced programming language is not equal to simple. However, the Python language is very easy to use for beginners and to accomplish common tasks. Even if Google is using Python on a massive scale, you won't have to worry about learning.

What can I do with python? Can do daily tasks, such as automatic backup of your MP3, can do website, many famous websites including YouTube is written by Python, can do online game backstage, many online game backstage are developed by Python. It's a lot of things to be able to do anyway.

Python, of course, does not have the ability to do things, such as writing the operating system, which can only be written in C language, mobile phone applications, only with Objective-c (for the iphone) and Java (for Android), write 3D games, preferably in C or C + +.

If you are a small white user, the following conditions are met:

    • will use a computer, but never write a program;
    • Also remember the mathematics of junior High school equations and a little bit of algebra knowledge;
    • Want to from the programming of small white into a professional software architect;
    • I can spare half an hour of study every day.

Don't hesitate, this tutorial is for you!

You ready?

(3) Python Hello World implementation

Example1:hello WORLD.C

  

#! /usr/bin/python
#coding: Utf-8 #如果python代码中会有中文, then add this line yo, or you know
print "Hello World!"

Yes, no. Utf-8 output Chinese is a problem, I am also a rib, encountered this issue

Example2:add.c

#! /usr/bin/python
#coding: Utf-8 #如果python代码中会有中文, then add this line yo, or you know
Import Sys #引入一个python的不知道算不算核心的包, I am also a beginner, I really do not understand

# Use the for command to print out the received parameters, SYS.ARGV is a type array of type, to receive the command line passed over the arguments
For a in SYS.ARGV:
Print A;

# User-transmitted parameters starting from 1, using the Len () function to get the number of parameters, this command should only have 2 parameters to
If Len (sys.argv)! = 3:
Print "Parameters should only be 2";
Sys.exit (); # Sys.exit () indicates exiting the program

NUM1 = Int (sys.argv[1]); # The most inconvenient place to use the Int () method to transfer the parameters into a digital type, to do the arithmetic
num2 = Int (sys.argv[2]);
Print str (NUM1) + "+" + str (num2) + "=" + str (NUM1 + num2); #数字型是不能方便的用print打印出来的, use the str () function to convert

As I expected, the scripting language is the scripting language, including the encoding format, similar to the previous Html,js,php,shell syntax. To declare the encoding format

(4)

http://limaoyuan.iteye.com/blog/1513147

http://www.liaoxuefeng.com/wiki/001374738125095c955c1e6d8bb493182103fac9270762a000

The beginning of python---hello world!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.