Python Basics-01

Source: Internet
Author: User

1. Simple classification of programming languages

The earliest machine language in advanced languages

Assembly

Advanced language: C language, Python,java,c++,c#,object-c

What kind of language is 2.python?

Compiled, interpreted, static, dynamic, strongly-typed, and weakly-type-defined languages.

Differences in compilation and interpretation: Using different methods

Explanatory: script Run

3. #python变量的命名规范

# 1. Can only be letter, number, underline composition

# 2. Cannot start with numbers or full numbers (mandatory)

# 3. Cannot be a python keyword def if while

# 4. Do not use Chinese

# 5. Don't be too long

# 6. Try to make sense

# 7. Recommended Use:

(1) Hump body: Capitalize the first letter of the word

(2) Underline: The words are separated by an underscore

4. #数据类型 (initial)

#在python中每个变量都是有类型的

# (1). Integer (int).

# (2). String (str).

#字符: A single text symbol you can see

#字符串: A bunch of characters arranged in a fixed order

#用 ', ', ', ', ' and '.

Note: print ("") #空字符串

Print ("") #空格字符串

# (3). Boolean (bool) pairs and wrongs, true and false. True,false

#type (variable) tells you what type this variable is.

5. #用户交互 input (Prompt). Will be returned to you to enter the content

Input ("Please enter your name:") #程序会停在这里, waiting for user input

S= "I'm named name, 18 years old this year."

Print (s)

A=input ("Please enter a:")

B=input ("Please enter B:")

#字符串转换成int

#int (str)

#c =int (a)

#d =int (b)

#print (C+d)

#常量 Immutable variables

There are no absolute constants in Python. We have a conventional. All the variable letters are in uppercase and constant.

# Print Statements

Print ("12", "13")

6. #条件判断

#if: If

else: #否则, content that is executed when the condition is not set

(1) If condition:

code block

Else condition:

code block

(2) If condition:

code block

Elif Conditions:

code block

Elif ...

Else

7. #语法:

While condition:

code block

Description: Determine if the condition is true. If true, execute the block of code (the loop body) and continue to determine whether the condition is true after execution. If it does, continue. Until the condition is false stop.

(1) #数数的问题

Index=1

While index<101:

Print (index)

Index=index+1

(2) #1 +2+3+4+...+100=?

Index=1

Sum=0

While index<101:

Sum=sum+index

Index=index+1

Print (sum)

#break: Interrupts the loop. Completely stop a loop (stop the current layer loop)

#continue: Stop this cycle. Continue with the next loop

(1) Index=1

While index<101:

Print (index)

Index=index+1

If index==88:

Break

(2) Index=1

While index<101:

If index==88:

Index=index+1

Continue

Print (index)

Index=index+1

Python Basics-01

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.