4、数据类型2

1、整数: int

2、浮点数(小数):float

3、转义字符:/   ,(\n:换行,\t:制表符,\\:\)

4、多个换行:'''...'''

print('''hello
tomorrow
11''')
hello
tomorrow
11

5、布尔值:True,Flase

>>> 3>2
True
>>> 3>4
False

布尔值可以用and ,or ,not计算

age=20
if age >= 18:
    print('shaonian')
else:
    print('dashu')
shaonian
-----------------------------
age=int(input('please enter your agers:'))
if age >= 18:
    print('shaonian')
else:
    print('dashu')
please enter your agers:20
shaonian

6、空值,(空值是Python里一个特殊的值,用None表示。None不能理解为0)

7、变量

动态语言
>>> a=123
>>> print(a)
123
>>> a='中间'
>>> print (a)
中间
---------------------------
静态语言
x=10
x=x+2
>>> print(x)
12
在程序中,赋值语句先计算下方的表达式x + 2,得到结果12,再赋给变量x。由于x之前的值是10,重新赋值后,x的值变成12。

a='abc'
b=a
a='xyz'
print(b)
abc

8、常量(在Python中,通常用全部大写的变量名表示常量)

>>> 10//3
3
>>> 10/3
3.3333333333333335
>>> 10%3
1
--------------------------------
n=123
f=456.789
s1='Hello,world'
s2='Hello,\'adam\''
s3=r'hello,"bart"'
s4=r'''hello,
lisa!'''
print('n=',n,'\nf=',f,'\ns1=',s1,'\ns2=',s2,'\ns3=',s3,'\ns4=',s4)
n= 123 
f= 456.789 
s1= Hello,world 
s2= Hello,'adam' 
s3= hello,"bart" 
s4= hello,
lisa!
------------------------------
name=input('please entry your name')
age=input('please entry your age')
city=input('please input your city')
print('name=,',name,'\nage=',age,'\ncity=',city)
please entry your namemike
please entry your age33
please input your cityjiujiang
name=, mike 
age= 33 
city= jiujiang

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值