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数据类型优化

    选择优化的数据类型原则: 1. 更小的通常更好 尽量使用可以正确存储数据的最小数据类型.更小的数据类型通常更快,因为它们占用更少的磁盘.内存和CPU缓存,并且处理时需要的CPU周期也更少. 2. 简单 ...

  2. 安卓自定义TextView实现自动滚动

    xml文件代码 <com.mobile.APITest.ScrollEditText android:id="@+id/statusEditText" android:lay ...

  3. 爬坑二 activiti流数据库版本错误引发的问题

    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'actModelCont ...

  4. 编译原理---antlr实践+编译过程理解+课程理解知识点

    0.其他说明 0.0编译器分为前.中.后端,课上主要学的是前端.前端又分为词法分析(lexical analysis).语法分析(syntax analysis).语义分析(semantic anal ...

  5. spring aop 切面编程

    import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; import java.util.Ha ...

  6. Python爬虫与一汽项目【一】爬取中海油,邮政,国家电网问题总结

    项目介绍 中国海洋石油是爬取的第一个企业,之后依次爬取了,国家电网,中国邮政,这三家公司的源码并没有多大难度, 采购信息地址: 国家电网电子商务平台 http://ecp.sgcc.com.cn/pr ...

  7. C sharp #001# hello world

    饮水思源:金老师的自学网站 索引 编写一个简单的控制台程序. 日期计算的结构化编程实现 日期计算机面向对象编程实现 直接应用已有组件 1.编写一个简单的控制台程序. using System; usi ...

  8. centos7 fortune+cowsay+lolcat美化初始终端

    前序 fortune+cowsay+lolcat效果图(每次打开新的终端的时候, 显示名言) fortune 提供我的rpm包, fortune+依赖 安装它们 rpm -ivh *.rpm 调配中文 ...

  9. Jquery中 .empty()和.append()

    jQuery empty() 方法:移除所选<div> 元素的内容: .empty()实例 jQuery append() 方法:在所选<> 元素结尾插入内容: .append ...

  10. Ubuntu: 安装自带的中文输入法

    1. 在终端安装输入法软件包 在终端输入 sudo apt-get install ibus-pinyin 2. 启用输入法 打开设置 找到Region&Language 找到Input So ...