Python练习-5

格式化输出
%s %d
%%
编码:
ascii 只能显示英文,特殊字符,数字。
万国码:unicode 最开始16位,中文不够32位 4个字节。
占用资源多。
升级:utf-8 utf-16 utf-32
utf-8:最少用一个字节,8位表示一个英文。
欧洲16位,两个字节。
亚洲 24位,三个字节。
gbk:中国国产,只能用于中文和ascii码中的文字。

什么数据类型。
int 1,2,3用于计算。
bool:True,False,用户判断。
str:存储少量数据,进行操作
'fjdsal' '二哥','`13243','fdshklj'
'战三,李四,王二麻子。。。。'
list:储存大量的数据。
[1,2,3,'泰哥','12353234',[1,2,3]]
元祖:只读。
(1,2,3,'第三方',)
dict:字典{'name':'云姐','age':16}
字典{'云姐':[],'二哥':[200,200,200,。。。。。。]}
集合:{1,2,34,'asdf'}
3,int。

4,bool。
5,str。

练习题

print(5 < 4 or 3)
print(2 > 1 or 6)
print(3 > 1 and 0)
#计算 1 - 2 + 3 ... + 99 中除了88以外所有数的总和
#1-2+3.。。,。+99
i=1
sum=0
while i <100:
    if i==88:
        i += 1
        continue
    if i%2!=0:
        sum=sum+i
    else:
        sum=sum-i
    i += 1
print(sum)

猜你喜欢

转载自www.cnblogs.com/LXL616/p/10623401.html