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. Linux基础命令---tload显示系统负载

    tload tload指令以字符的方式显示当前系统的平均负载情况. 此命令的适用范围:RedHat.RHEL.Ubuntu.CentOS.Fedora.SUSE.openSUSE.   1.语法   ...

  2. redis 在 php 中的应用(key篇)

    本文为我阅读了 redis参考手册 之后结合 博友的博客 编写,注意 php_redis 和 redis-cli 的区别(主要是返回值类型和参数用法) 目录: KEY(键) DEL           ...

  3. Spring Cloud Zuul 中文文件上传乱码

    原文地址:https://segmentfault.com/a/1190000011650034 1 描述 使用Spring Cloud Zuul进行路由转发时候吗,文件上传会造成中文乱码“?”.1. ...

  4. QSettings 类

    一 .QSettings介绍: 用户通常希望应用程序记住其设置.在windows中,这些设置保存在注册表中,ios在属性文件列表中,而unix,在缺乏标准的情况下,其存储在ini文本中.QSettin ...

  5. java导出excel,多表头合并

    要求结果图如下: 有空补充具体逻辑 参考:https://blog.csdn.net/dj0721/article/details/72463042 HSSFColor  背景颜色选择  参考:htt ...

  6. bootstrap 简单练习(后续把其它页面也进行练习)

    <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <m ...

  7. AutoCAD2015有时候会显示乱七八糟的线

    问题描述:AutoCAD2015以上版本有时候打开一张图,会出现乱七八糟的线 解决方案: 这是由于硬件加速平滑线显示引起的,可以如下修改

  8. loadrunner 参数化取值方式详解

    参数化对话框中与参数取值方式有关的区域如下: 改变参数化的取值方式,关键在于Select next row和Update value on这两个选项. Select next row包括以下选项: S ...

  9. linux 修改普通用户的 max user process

    因为出现  fork: retry: No child processes 问题 , google了一下 , 大家说是要去修改 /etc/security/limits.conf 文件 , 然后我用r ...

  10. rsyslog+loganalyzer配置

    1.loganalyzer服务器搭建[root@localhost ~]# getenforce #查看selinux是否关闭[root@localhost ~]# setenforce 0 #临时关 ...