当前位置:网站首页>Day2- syntax basis and variables
Day2- syntax basis and variables
2022-06-26 05:47:00 【m0_ sixty-seven million thirty-six thousand three hundred and f】
Summary of learning
The output function is to output the data in the program to the console
Input function : The program obtains data from the console
1.input function ( adopt input The result of the input data is a string , Cannot be applied to operations , To convert )
Variable = input( Enter the prompt message ) - Prompt the user to enter content , And save the input to the variable
age = input(' Please enter your age :')
print(age)
# Prompt the user for name, age and phone number
name = input(' Please enter your name :')
number = input(' Please enter your phone number :')
print(name, number)
print(' full name :',name, ' Telephone :', number)
2. Output function
print Is to display the data in the program on the console ( Print ) come out , All the contents displayed on the console must be print Printed content
1) Basic usage
a. One print Print a data
b. One print Print multiple data :print( data 1, data 2, data 3,…)
print(10, 20, 3,)
print(type(10.3), 10 + 2, type(' Hello '))
number = 11233
print(number)
2) Advanced usage
By default, a print The printed content occupies one line
a. customized end:print( data 1, data 2, end=’’)
Printing principle : Program designation print During operation , Will print the data first , And then print it end Value (end The default is line feed )
print(12, 15, end=' ')
print(11)
print(12)
If you want a blank line, enter an empty print()
print(11,end=';')
print(1)
print()
print(3)
b. customized sep
customized sep It is used to control when printing data at the same time , How data is separated from data , Default is space
print(1, 2, 3, sep=',')
print(1, 2, 3, sep=';')
print(1, 2, 3, sep='\n') # \n It's line changing
print(1, 3, 2, sep=',', end=';')
print(1, 3, 2, end=',', sep=';')
3. notes
1) Single-line comments
ctr +/ Automatic generation
2) Multiline comment
Put the content between double quotation marks or single quotation marks in three English States
3) The function of annotation
a. Annotate the code with , Improve the readability of the code
b. Cancel code function
4. Lines and indents
1) That's ok
python One line of code , You can leave a semicolon at the end of a line
print('hello')
print(' Hello ')
If you have to display multiple statements on one line , Semicolons must be used between statements
print('hello');print(' Hello ')
2) Indent - The space before a statement is called indentation
A statement cannot be preceded by a space
5. Identifiers and keywords
1) identifier - Naming requirements
python Identifier requirements : By letter 、 Numbers or underscores , And numbers don't start ( There can be no symbols other than these three )
a = 100
a1 = 100
a1_ = 100
2) keyword - python Some identifiers with special functions or special meanings in
Print all keywords
from keyword import kwlist
print(kwlist)
6. Common data and data types
1) Digital data : Data used to represent the size of a numeric value , For example, age 、 height 、 distance , amount of money
The method of representing digital data in a program : The same way that numbers are represented in Mathematics , Support scientific counting
The type corresponding to the number : Digital data is divided into integer types (int) And floating point (float) Two kinds of
2) Text data : It is used to represent the data corresponding to text information , for example : full name , Address , School name , Phone number , Zip code , Id card number
Representation : Text data must be enclosed in double or single quotation marks
type : character string (str, Abbreviations of words )
3) Boolean data : Only True and False Two values ,True It means true , To affirm ,False It means false , Denying
(True and false Is the key word )
Representation : direct writing True perhaps False, Don't add any characters
type : Boolean ( English translation ,bool)
4) Null value :None( It means nothing )
keyword :None
type :None Type
7. operation
1) Get data type :type( data ) - Gets the type of the specified data
type(3.2)
print(type(3.2))
print(type(True))
print(type(' Hello '))
character string ( Text data )
2) Type conversion : Type name in parentheses - Converts the specified data to the specified type
take 10.9 Convert to integer
int(10.9)
print(int(10.9))
Homework
choice question
- B
- C
- B
- C
- D
Completion
- #; “”“ ”“”
- 10;20
- .py
- integer
- Single quotation marks ; Double quotes
- two ;Ture、False
- type
Programming questions
x = str(input(' Please enter a user name :'))
y = int(input(' Please input a password :'))
print(' user name :', 'x', ' password :', y)
x, y, z = 1, 2, 3
print(x, y, z, sep='=')
Short answer
The variable name is named by the programmer ; Is an identifier. , It can't be a keyword ; When you choose a name, you should see the name and know the meaning , Do not use system function names 、 Class name and module name , The letters are all lowercase , Multiple words are separated by underscores .
1) Easy to learn
2) High development efficiency
3) Explanatory language , Platform portability
4) It supports both mainstream programming paradigms
5) The degree of standardization , High readability
1) Data analysis
2) Artificial intelligence
3) Quantum trading
4) Network data collection
5) automated testing
6) machine learning
边栏推荐
- 国务院发文,完善身份认证、电子印章等应用,加强数字政府建设
- [MySQL] MySQL million level data paging query method and its optimization
- Something about MariaDB
- Command line interface of alluxio
- Win socket programming (Mengxin initial battle)
- BOM文档
- Daily production training report (17)
- 小程序第三方微信授权登录的实现
- The State Council issued a document to improve the application of identity authentication and electronic seals, and strengthen the construction of Digital Government
- Introduction to lcm32f037 series of MCU chip for motor
猜你喜欢

Command line interface of alluxio

Sofa weekly | open source person - Yu Yu, QA this week, contributor this week

家庭记账程序(第一版)

Consul服务注册与发现

Introduction to GUI programming to game practice (I)

怎么把平板作为电脑的第二扩展屏幕
![[arm] build boa based embedded web server on nuc977](/img/fb/7dc1898e35ed78b417770216b05286.png)
[arm] build boa based embedded web server on nuc977

11 IO frame

pytorch(环境、tensorboard、transforms、torchvision、dataloader)

Uni app ceiling fixed style
随机推荐
Data storage: the difference between MySQL InnoDB and MyISAM
BOM document
421-二叉树(226. 翻转二叉树、101. 对称二叉树、104.二叉树的最大深度、222.完全二叉树的节点个数)
A new explanation of tcp/ip five layer protocol model
cross entropy loss = log softmax + nll loss
FindControl的源代码
虚拟项目失败感想
June 3 is a happy day
10 set
Life is so fragile
AutowiredAnnotationBeanPostProcessor什么时候被实例化的?
组合模式、透明方式和安全方式
SDN based DDoS attack mitigation
Redis installation on Linux
Describe an experiment of Kali ARP in LAN
Navicat如何将当前连接信息复用另一台电脑
[PHP] PHP two-dimensional array is sorted by multiple fields
A love that never leaves
Written before father's Day
redis探索之布隆过滤器