The first Python code

Source: Internet
Author: User

Today wrote the first Python code, very bothered, because the space alignment is not correct, how can not run out, but very excited is finally in my efforts, with the results. And thank God for taking me to the first Python project.

Look at the code first:

#!/usr/bin/python  #if__name__  =  "__main__" #print   "hello, world!" #age =10#name= "Bill" #print   '% s is % d years old '%  (Name,age) class  Student:                           #类名首字母要大写, other letters in lowercase __name =  ""                      # The private instance variable must have two underscores before def __init__ (self,name): self.__name=name       # Self is equivalent to the thisdef getname (self):return self.__name      #方法名首字母用小写 in C + +. The first letter of each word is then capitalized if __name__ ==  "__main__":               #相当于C语言的mian函数student  = student ("Yang")       # Object name in lowercase letter print student.getname ()

Operation Result:

Yang


Python features: 1. Object-oriented features (elimination of protection types, abstract classes, interfaces and other aspects of object-oriented elements);

2. Simplicity (less reserved words, no semicolons, begin,end, etc.), code blocks using spaces or tabs

indentation, delimited code,)

3. Built-in data structure

4. Robustness

5. Cross-platform

6. Extensibility

7. Dynamic Nature

8. Strongly typed languages

9. Widely used


This article from the "Learning Record" blog, reproduced please contact the author!

The first Python code

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.