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. Mysql如何进行分组,并且让每一组的结果按照某个字段排序,并且获取每一组的第一个字段

    select * from (select * from table_name order by id desc) h where h.catagory_id in(value1,value2,val ...

  2. element-ui表单form和rules踩坑

    问题: 代码: <el-form ref="form" :rules="rules" :model="form" label-widt ...

  3. 安装redis报错 you need tcl 8.5 or newer in order to run redis test

    解决方法: wget http://downloads.sourceforge.net/tcl/tcl8.6.1-src.tar.gz tar -zxvf tcl8.6.1-src.tar.gz -C ...

  4. 如何在Ubuntu 16.04上安装PythonGDAL 2.1?

    sudo add-apt-repository -y ppa:ubuntugis/ubuntugis-unstable sudo apt update sudo apt upgrade # if yo ...

  5. 远程执行shell脚本的小技巧

    很多时候需要批量跑脚本执行任务,但又不想分发再执行,而是直接一条命令下去就跑脚本,该怎么玩比较嗨? 例如以下脚本: #!/bin/bash echo "$@" echo " ...

  6. linux文件查找-find和locate

    一.find 使用语法:find  [查找目录]  [查找规则]  [查找完后执行的action] find是根据具体目录进行搜索 1.查找目录 如果不指定查找目录,默认在当前目录下进行查找 如果需要 ...

  7. wqweqweqwe

    本文目录 1 会话跟踪技术 2 cookie介绍 Django中操作Cookie Session Django中Session相关方法 Django中的Session配置 CBV中加装饰器 回到目录 ...

  8. centos7 harbor 单机搭建

    环境说明:centos 7.4 下面使用的域名是自己编造 可自行设置使用 域名在centos7.4 系统做解析 在windows vhost文件也做解析 分享压缩包  因github下载过慢  所以我 ...

  9. BZOJ 3473 字符串

    思路 广义SAM的题目,先全部插入,然后每个字符串在SAM上匹配,如果发现当前sz小于k(就是前缀不满足条件),就跳fail(找前缀的后缀,就是找子串)到满足条件为止,然后一个满足条件的节点,它的所有 ...

  10. 如何解决 React 官方脚手架不支持 Less 的问题

    说在前面 create-react-app 是由 React 官方提供并推荐使用构建新的 React 单页面应用程序的最佳方式,不过目前版本(1.5.x)其构建的项目中默认是不支持动态样式语言 Les ...