程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

[Python basics] variables, operators, data input and output

編輯:Python

python Interpreter : take python The code is translated into a language that the machine can understand , And execute the code .
Pycharm:python Code editor .

One 、 Understanding variables

A variable is an area of memory .
Variable name : In letters , Numbers and underscores make up , Cannot start with a number .
python in , There is no need to set the type when defining variables .

Two 、 Cognitive operator

1、 value type
python Supported by 5 Types :int integer ,float floating-point ,bool type ,complex Plural
Long integers now fall into int integer .

In particular, the value specified in the scientific counting method is counted as floating point type

bool Type return ture perhaps false

2、 Cognitive operator

1) Arithmetic operator : +,-,*, **,/,%,//
among ** Representative power ,% For taking the rest ,// It stands for division .
2) Assignment operator :=,+=,-=,l=,*=,%=
Specific reference examples
3) Relational operator :>,>=,<,<=, !=,==
among = For assignment ,== For judgment .
4) Logical operators : Logic and and, Logic or or, Logic is not not
among , Logic and , The whole is true , One false is true .
Logic or , All false is false , One is true .
Logic is not , False is true , True is false .

Examples of arithmetic operators
Example of assignment assignment operator

Examples of relational operators
Return to bool value

Examples of logical operators

3、 ... and 、 Data input and output

1、input For input

2、 Convert data type
int() Convert data to integer
float() Convert data to floating point
bool() Convert data to Boolean
use int Define input
Does not define int, Direct comparison error

Definition int after , It can be compared with the numerical value

3、 Output
%s character string ,%d Integer is placeholder


.xf Represents the decimal places omitted to the floating-point point

You can also use format Format printing

Four 、 test



  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved