Day1 python basics notes, if the statement

What kind of language python

编译型

执行速度快

开发速度慢

解释型

执行速度慢

开发速度快

variable

a = 35 +36
print(a)
b = a * 2 
print(b)
pring(1+a)


a = "香水"  # 声明变量

Variable frequently used in the program

Variable rules

1. 变量 由字母,数字,下划线组成

2. 数字不能开头

3. 不能使用python关键字

4. 不能使用中文和拼音

5. 区分大小写

6. 变量名要具有描述性意义

7. 推荐写法

   驼峰体

      大峰

      小峰

   下划线

   age_of_oldboy = 98(官方推荐)

   

constant

Constant is declared in the configuration file

ID = 11111111111

age = 18

age1 = 19

age2 = age

age = 20

print(age,age1 age2)

Operational priorities: equal sign on the right> left

Note

Single-line comments (comment when the row) "", '', as line

Multi-line comments

"" "" "", '' '' '' May wrap, but must first multi-wall quotes

Underlying type

Int int 1 .... ∞ for calculating and comparing the

The string "Hello" in python as long as the quotes of this is due to a string

a = "1"

b = "2"

c = "3"

print (a + b + c) # string concatenation

d = "Television"

print (d * 8) # string can only multiply the number

'' 'My name's "meet"' '' with the use of quotation marks

Boolean value

Returns the truth value for determining

True

False

print(3>2) T

print(3<2) F

User interaction

input () # user interaction

intput ( "precautionary statements")

input acquired are strings

a = input("请输入账号,然后回车:") # input获取到的都是字符串
print(int(a)+5)

Control flow statements

Single if

Keyword space colon condition

Indent results

if 3 > 2:
a = input("asd")
print(a)

print(1)
if 3<2:
print(2)
print(3)

if else a second election

if the space colon condition

Indent results

else colon

Indent results

a = int (input ( "Enter"))

if a > 10:

​ print(1)

else:

print(2)

if elif elif a multiple choice or zero

print(110)

if 3<2:

​ print("A")

elif 3>8:

​ print("B")

elif 5 <0:

​ print("C")

print(112)

if elif else a multiple-choice

if 3 == 2:
print(1)
elif 3 < 2:
print(3)

elif 3 > 10:
print(10)
else:
print(9)

if if if multiple choice

if 3>2:

​ print("A")

print("B")

if 5>2:

​ pring("C")

if nested

sex = "女"

age = 35

if sex == "女":

​ if age == 35:

print ( "come sit.")

​ else:

print ( "You go next door to find Chunsheng")

else:

print ( "You go door to find alex")

= A 'Alex'
B = 'Alex is a big biscuits'
C = INPUT ( "Please enter the account number")
D = INPUT ( "Please enter the password")
IF A == C:
IF D == B:
Print ( "successful login ")
the else:
Print (" password error ")
the else:
Print (" error account ")

to sum up

A .python history

The difference python2 and python3

The birth of Django framework 2004

Two .python programming language

python is an interpreted language

Three types of .python

Cpython jpython ironpython pypy

IV. Variables

  1. Variables are letters, numbers, underscores

  2. Prohibition start with numbers

  3. Prohibit the use of python keywords

  4. You can not use Chinese and Pinyin

  5. Variable names are case-sensitive generations

  6. Recommended wording

    Hump ​​body, underscore

    age_of_oldboy = 98 (the official recommended)

    A variable name only one in memory

    V. Constant

    Variable name in all caps is constant - constant modification is not recommended

    VI. Notes

    Single-line comments

    Multi-line comments

    VII. Basic data types

    int-- integer (numbers) are calculated and compared

    str-- string (letters, characters)

    Boolean for determining bool--

    VIII. User interaction

    input () Note: input to obtain the contents of all strings

    IX. Flow control statements

    Single if

    if else a second election

    if elif elif a multiple choice or zero

    if elif elif else is selected from a plurality of

    if if if multiple-choice or more than zero

    Analyzing be nested if multilayer layer 3 is generally about nested if

10. Other knowledge

And front and rear and is the true and are true

type () to view the data type

int ( "5") is converted into integer string 5

str (5) to convert an integer to a string

Are equal before and after the determination ==

Guess you like

Origin www.cnblogs.com/zhuzhizheng/p/11134026.html