Home  >  Article  >  Backend Development  >  python system learning examples

python system learning examples

零下一度
零下一度Original
2017-07-26 09:41:431429browse

Today I started systematic learning of python and started writing essays. I hope it will be helpful to people who see it.

Preview:

1. Install python2 and python3 to achieve multi-version coexistence

2 , write code in python language, require input of user information: name, age, home address, and then print

3. The old boy’s age is 63, and it is required to create a game for guessing the age of the user. If the entered age is too small, the prompt is: too small. If the user enters the age, the prompt is: too big. If the user guesses the age correctly, the prompt is: you get it

Python introduction:

The founder of python is Guido van Rossum. During the Christmas period of 1989, Guido started writing a compiler for the Python language. The name Python comes from Guido’s beloved TV series Monty Python’s Flying Circus. He hopes that this new language called Python can meet his ideal: to create a language between C and shell that is comprehensive, easy to learn, easy to use, and scalable. Python ranks fourth in the latest programming language rankings.

Python is an interpreted language.

Python application fields:

web full-stack development, network programming, crawlers, cloud computing, artificial intelligence, Automated operation and maintenance, financial analysis, scientific computing, game development, etc.

Among them, Python is in a dominant position in the crawler field, and is also in a leading position in cloud computing, artificial intelligence, and automated operation and maintenance.

The current development of python:

Now both python2.7 and python3.6 are officially supported, but python2 .7 is just an interim version, and the future trend will be python3.6, so I personally recommend that those who want to learn python can directly learn the python3.6 version. Python 2.7 exists because many companies in the industry are still using Python 2.7 extensively. It is not easy to quickly upgrade old projects with hundreds of thousands or even millions of lines of code to 3.0, but almost everyone uses it when developing new projects.

The first python program:

1 print("hello world!")

##Preview answer:

1. After installing python2.7 and python3.6. Copy and rename python in the installation directory as shown in the picture.

#Remember that copying and renaming cannot be renamed directly. Otherwise, an error will be reported.

2

Enter user information: name, age, home address, and then print

1 #要求输入用户信息:姓名,年纪,家庭住址,然后打印2 name = input("name:");3 age = input("age:");4 address = input("address:");5 6 print("======egon info======");7 print("name:",name,"age:",age,"address:",address);8 print("=====================");

Result:

3. Guess age Game:

 1 print("猜年龄游戏:") 2 age = int(input("请猜猜老男孩的年龄:")) 3 while age != 63 : 4          5     if age < 63 : 6         print("too small") 7      8     else : 9         print("too big")10     11     age = int(input("请猜猜老男孩的年龄:"))12 print("you get it")
Result:


##Little knowledge points:

bin() is used to convert decimal to binary

oct() Used to convert decimal to octal

##hex() Used to convert decimal to hexadecimal

exit() to exit.

Note that the missing bits in front are added with 0. Example: 00010100

The above is the detailed content of python system learning examples. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn