1.day1作业讲解

题目答案见day1

2.格式化输出

%占位符,s:字符串,d:数字

%%只是单纯的显示%(显示的%是后面的)

 #格式化输出
# % s d
# name = input('请输入姓名')
# age = input('请输入年龄')
# height = input('请输入身高')
# msg = "我叫%s,今年%s 身高 %s" %(name,age,height)
# print(msg) name = input('请输入姓名:')
age = input('请输入年龄:')
job = input('请输入工作:')
hobbie = input('你的爱好:') msg = '''------------ info of %s -----------
Name : %s
Age : %d
job : %s
Hobbie: %s
------------- end -----------------''' %(name,name,int(age),job,hobbie)
print(msg) name = input('请输入姓名')
age = input('请输入年龄')
height = input('请输入身高')
msg = "我叫%s,今年%s 身高 %s 学习进度为3%%s" %(name,age,height)
print(msg)

3.while else语句

 count = 0
while count <= 5:
count += 1
if count == 3:break print("Loop",count) else:
print("循环正常执行完啦")
print("------ out of while loop ------")

注:当while循环被break打断,就不会执行else的结果

4.初始编码

01010100        新
11010000        开
11010100        一
01100000        家
11000000        看
11000000        看

01010100011101110101011110110
A B C
01000001 01000010 01000011
电报,电脑的传输,存储都是01010101

最早的'密码本' ascii 涵盖了英文字母大小写,特殊字符,数字。
01010101
ascii 只能表示256种可能,太少,
创办了万国码 unicode
    16表示一个字符不行,32位表示一个字符。
    A  01000001010000010100000101000001
    B  01000010010000100100001001000010
    我 01000010010000100100001001000010
Unicode 升级 utf-8  utf-16 utf-32
    8位 = 1字节bytes
    utf-8 一个字符最少用8位去表示,英文用8位  一个字节
          欧洲文字用16位去表示                两个字节
          中文用24 位去表示                   三个字节
    utf-16 一个字符最少用16位去表示

gbk 中国人自己发明的,一个中文用两个字节 16位去表示。

11000000

1bit    8bit = 1bytes
1byte   1024byte = 1KB
1KB     1024kb = 1MB
1MB     1024MB = 1GB
1GB     1024GB = 1TB

5.逻辑运算

1.优先级 () > not > and > or

2.int ----> bool (数字转换成布尔值) 非零转换成bool True 0 转换成bool 是False

3.x or y x True,则返回x

4.x and y x True,则返回y

 # and or not
#优先级 () > not > and > or
#print( 2 > 1 and 1 < 4 )
#print ( 2 > 1 and 1 < 4 or 2 < 3 and 9 > 6 or 2 < 4 and 3 < 2)
# T or T or F
#T or F
# print(3>4 or 4<3 and 1==1) # F
# print(1 < 2 and 3 < 4 or 1>2) # T
# print(2 > 1 and 3 < 4 or 4 > 5 and 2 < 1) # T
# print(1 > 2 and 3 < 4 or 4 > 5 and 2 > 1 or 9 < 8) # F
# print(1 > 1 and 3 < 4 or 4 > 5 and 2 > 1 and 9 > 8 or 7 < 6) # F
# print(not 2 > 1 and 3 < 4 or 4 > 5 and 2 > 1 and 9 > 8 or 7 < 6) # F #ps int ----> bool (数字转换成布尔值) 非零转换成bool True 0 转换成bool 是False
# print(bool(2))#T
# print(bool(-2))#T
# print(bool(0))#F
# #bool --->int
# print(int(True)) # 1
# print(int(False)) # 0 '''x or y x True,则返回x'''
# print(1 or 2) # 1
# print(3 or 2) # 3
# print(0 or 2) # 2
# print(0 or 100) # 100 # print(2 or 100 or 3 or 4) # 2 # # print(0 or 4 and 3 or 2) # x and y x True,则返回y
# # print(1221Q 1234
# ,。and 2)
# # print(0 and 2)
print(2 or 1 < 3)
print(3 > 1 or 2 and 2)

day 02 python 基础的更多相关文章

  1. 02.python基础知识_02

    数据类型 1.整型 2.布尔值 3.字符串 4.列表 5.字典 6.集合 1.int(整型) i = 2 print(type(i)) 输出:<class 'int'> 2.bool(布尔 ...

  2. python基础之02列表/元组/字典/set集合

    python中内置的数据类型有列表(list)元组(tuple)字典(directory). 1 list list是一种可变的有序的集合.来看一个list实例: #第一种方法: >>&g ...

  3. Python基础教程-02

    <Python基础教程> 第3章 使用字符串 字符串方法find返回的并非布尔值.如果find像这样返回0,就意味着它在索引0处找到 了指定的子串 join可合并一个字符串列表,不能合并数 ...

  4. Python基础+Pythonweb+Python扩展+Python选修四大专题 超强麦子学院Python35G视频教程

    [保持在百度网盘中的, 可以在观看,嘿嘿 内容有点多,要想下载, 回复后就可以查看下载地址,资源收集不易,请好好珍惜] 下载地址:http://www.fu83.cc/ 感觉文章好,可以小手一抖 -- ...

  5. python基础——类和实例

    python基础——类和实例 面向对象最重要的概念就是类(Class)和实例(Instance),必须牢记类是抽象的模板,比如Student类,而实例是根据类创建出来的一个个具体的“对象”,每个对象都 ...

  6. python基础——使用模块

    python基础——使用模块 Python本身就内置了很多非常有用的模块,只要安装完毕,这些模块就可以立刻使用. 我们以内建的sys模块为例,编写一个hello的模块: #!/usr/bin/env ...

  7. 第一篇:python基础

    python基础   python基础 本节内容 python起源 python的发展史 为什么选择python3 第一个python程序 变量定义 表达式和运算符 用户输入 流程控制 判断 流程控制 ...

  8. python基础教程

    转自:http://www.cnblogs.com/vamei/archive/2012/09/13/2682778.html Python快速教程 作者:Vamei 出处:http://www.cn ...

  9. Python基础-week05

    本节大纲:Author:http://www.cnblogs.com/Jame-mei 模块介绍 time & datetime模块 random os sys shutil json &am ...

随机推荐

  1. vue使用v-for时vscode报错 Elements in iteration expect to have 'v-bind:key' directives

    vue使用v-for时vscode报错 Elements in iteration expect to have 'v-bind:key' directives Vue 2.2.0+的版本里,当在组件 ...

  2. GO map

    map是一种无序的基于key-value的数据结构,Go语言中的map是引用类型,必须初始化才能使用. map定义 语法:map[KeyType]ValueType KeyType:表示键的类型. V ...

  3. 【annotation】非人类物种基因组注释(MSU为例)

    基因组注释工具ANNOVAR是一款非常好用的注释软件,功能强大,输出数据简单美中不足就是对于非人类物种来说UI不够完善,因此总结一下整个注释的过程,帮助别人快乐自己. 首先我们需要明确我们需要的数据和 ...

  4. MTK-LCM 屏幕使用fbconfig/PanelMaster来调试LCM驱动

    屏幕调试是我们做的较多的工作,且以MIPI屏为主,调试时总是会遇到一些参数需要一点一点配的时候,这样的工作其实很是繁琐,在我们确认完硬件没有问题时能不能使用简易的方法来解决这个问题呢 ? MTK已经为 ...

  5. pandas替换一列中的汉字为数字

    表格的一列“总金额”应该全部为数字,但其中少数项出现汉字,应该将汉字替换为数字,才能进行后面的计算. 先定义一个函数: def is_number(s): try: float(s) return T ...

  6. 读取本地json文件,并转换为dictionary

    // 读取本地JSON文件 - (NSDictionary *)readLocalFileWithName:(NSString *)name { // 获取文件路径 NSString *path = ...

  7. 七夕节快到了,做个图钉画以及学习下Pillow吧

    又有时间写东西了,最近深感世事并不以人的美好愿望而改变,还是要以积极地心态来适应新变化,多多关心身边的人. 图钉画中一个图钉代表一个像素,所以关键在于像素渣化,降低分辨率,图钉的色彩有限,还需要降低图 ...

  8. 在ubuntu的bash中循环执行脚本,并在内存不足时重启

    #!/bin/bash date ma=`grep MemAvailable /proc/meminfo | awk '{print $2}'` echo MemAvailable = $ma run ...

  9. android开发_文本按钮 与 输入框

    1 TextView:    属性与值 android:text="文本" android:textSize="20sp"              //sp为 ...

  10. 场景:如果一个select下拉框的值被选中,其他两个字段值的校验也生效

    $("#operationType").change(function(){ if(this.value==1){ $('[name="assigneeCardType& ...