Python Learning Diary 3/9

Source: Internet
Author: User
Tags ruby on rails

Part 12 Binary

Slightly

Part 2 character encoding and computer capacity

1.ascii yards

2. Computer capacity

1 bit = 1bit

Bit is the smallest storage unit in the computer;

8bit = 1 bytes (Bytes)

Every single character in the ASCII code table requires 8 bits, or 1 bytes, to be stored;

1024bytes = 1KBytes = 1KB

1024kbytes = 1Mbytes = 1M

1024M = 1Gigabytes

1024GB = 1TB

1024TB = 1PB

Part 3 Introduction to programming languages

What is a programming language

Define a set of grammar rules that interact with your computer, which is called a programming language

Learn to Program = = Learn grammar rules

What can be programmed to do?

Print Hello World

Eject CD

A bunch of command combinations = = "Software

There are many grammatical rules that interact with computer love, 600+

C = Development language for each operating system 1973

C + + = Enhanced version 1983 of the C language

java = 1995 developed by Sun, Java Virtual Machine supports cross-platform

PHP = 1994, Pure Web development language

Python = 1989, born at the same time as Linux, was just started as a scripting language, the 1991 official version

C#

Ruby

Ruby on Rails:web Frame

Prel = language developed on UNIX platforms, very powerful in word processing

Shell = scripting language, simple and easy to learn, based on Unix,linux, do some simple system management tasks, operations and maintenance personnel must learn

Scalar = can be run directly on a Java virtual machine for big data development

Erlang = Functional Programming

Go = Google released in 2009, dedicated to multiprocessor system applications

JavaScript = The most widely used language of the moment, mainly written in the front-end language

Nodejs = backend, full-stack language

LUA = Nginx scripting language Nginx is the most NB Web server nowadays.

Part 4 Developing language classifications

Compiled: The program needs a special compilation process before execution, the program is compiled into a machine language file, the runtime does not need to re-translate, directly using the results of the compilation is OK. The program executes efficiently, relies on the compiler, the cross-platform is inferior.

Translate all, then execute EG:C C + +

Interpreted: The program code is stored in text mode without pre-compiling. When you publish a program, it appears that you are saving the compile operation. However, when you run the program, the explanatory language must first be interpreted and then run .

Edge execution side translation Eg:python php java C # Ruby JS

Part 5 file suffix

  The file suffix indicates the file extension, which identifies the file type

. txt Notepad text file

. exe executable file

. py Python File

. Java Java File

. C. h C source code

. php php File

Part 6 python Installation and environment variable configuration

Slightly

How to execute a PY program

1. Interactive device

Cons: Files cannot be saved permanently

Mainly used for simple grammar test related

2. File Execution

Prat 7 Variable explanation

Variable

Variables are stored in order to store some intermediate results in the program operation, in order to facilitate later invocation

Variable naming rules

1. Variable names should be descriptive

2. Variable names can only be made up of numbers, letters, underscores, not special characters (including spaces)

3. Cannot use Chinese as variable name

4. Cannot start with a number

5. Reserved characters are not allowed to be used

Constant

Generally use all uppercase letters to denote constants

Part 8 character encoding

Support for the first table in Chinese GB2312

1980 GB2312 6700+

1995 gbk1.0 20000

27000 GB18030

Unicode Universal code support for all countries and regions encoding all characters require two bytes

Utf-8 Unicode extension set, variable-length character encoding set

Python 2.x = = acsii default encoding

Python 3.x = = Unicode default encoding

In order for Python 2.x to display Chinese, you need to tell the compiler to use UTF-8 encoding

# !-*-Coding:utf-8-*-
#coding: Utf-8
#一般使用第一种Print u" I love Beijing tian ' an gate"

Convert to Unicode encoding after you add u

Unicode backwards compatible gb2312 GBK

Comments

Single-line Comment #

Multiline comment "" or "" "" ""

Part 9 user input

  

Name = input ("Your name:") Age= Int (Input ("Your Age:"))#all data received by input is a string, even if the input is a numberRest= 100- AgePrint(Name,"You can still live for", rest,"years ...")Print(Name +"You can still live for"+ STR (REST) +"years ...")

Note that if separated by commas, each part is relatively independent, does not require a string, and the output is separated by a space; if you use the + link, each part must be a string and will not be separated by a space.

Output Result:

Python Learning Diary 3/9

Related Article

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.