?Python:运算与循环
name = input(=input(=input(=input(= %(msg)
<div class="cnblogs_code">
name = input(= input(= input(=%(name,age,height)
name = input(= input(= input(= %(name,age,height)
2、while else与其它语言else 一般只与if 搭配不同,在Python 中还有个while ...else 语句 while 后面的else 作用是指,当while 循环正常执行完,中间没有被break 中止的话,就会执行else后面的语句 count = count <= 5+= 1
(<span style="color: #0000ff">else<span style="color: #000000">:
<span style="color: #0000ff">print(<span style="color: #800000">"<span style="color: #800000">循环正常执行完啦<span style="color: #800000">"<span style="color: #000000">) <span style="color: #0000ff">print(<span style="color: #800000">"<span style="color: #800000">-----out of while loop ------<span style="color: #800000">") 输出: 如果执行过程中被break啦,就不会执行else的语句 count = count <= 5+= 1
count == 3:
(<span style="color: #0000ff">else<span style="color: #000000">:
<span style="color: #0000ff">print(<span style="color: #800000">"<span style="color: #800000">循环正常执行完啦<span style="color: #800000">"<span style="color: #000000">) <span style="color: #0000ff">print(<span style="color: #800000">"<span style="color: #800000">-----out of while loop ------<span style="color: #800000">") 输出: 3、初始编码(1)最早的密码本-ASCII码,最早是七位,涵盖了英文字母,大小写,特殊字符,数字。预留1位,以备拓展,所以ASCII是8位。(2)ASCII 只能表示256种可能,太少,创办为万国码。Unicode。Unicode开始用16位表示一个字符,不行。升级为32位表示一个字符。但是Unicode表示一个字符太长,升级为utf-8、utf-16、utf-328位 =1字节bytesutf-8 一个字符最少用八位来表示,英文用八位,欧洲的文字用16位来表示,中文用24位来表示utf-16 一个字符最少用16位来表示。(3)GBK 中国人自己发明的。一个字节用两个字节 16位去表示。 1bit(位) 8 bit=1bytes 1 byte 1024byte=1KB 1kb 1024kb =1MB 1MB 1024MB= 1GB 1GB 1024GB =1TB 4、基本运算符 (1) 逻辑运算 nor>and>or
(2>1 1<4 (2>1 1<4 2<3 9>6 2>41,3>4 4<3 1==1
2,1 < 2 3 < 4 1>2
3,2 > 1 3 < 4 4 > 5 2 < 1
4,1 > 2 3 < 4 4 > 5 2 > 1 9 < 8
5,1 > 1 3 < 4 4 > 5 2 > 1 9 > 8 7 < 6
6, 2 > 1 3 < 4 4 > 5 2 > 1 9 > 8 7 < 6'''
1,F or F False2,T or F True3,T or F True4,F or F or F False5,f or f or f False6,f or f or f False ''' <div class="cnblogs_code">
(1 2)
(0 2 )
(1 2)
(0 2)
(1>2 3 4 )
bool 非零转换成bool 为true 0转换成bool值为false。
(bool(2 (bool(2- int
(int(True))
(int(False))
? (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |