# -*- coding:utf-8 -*-
count = 1
while count <= 10:
print(count)
count = count + 1


# -*- coding:utf-8 -*-
#打印1 2 3 4 5 6 8 9 10
#方法一
# count = 1
# while count <= 10 :
# if count < 7:
# print(count)
# count = count + 1
# elif count >7:
# print(count)
# count = count + 1
# else:
# count = count + 1
#错误的方法 会导致只打印到6
count = 1
while count <= 10 and count !=7:
print(count)
count = count + 1
#上面的纠正
count = 1
while count <= 10 :
if count !=7:
print(count)
count = count + 1
#或者
count = 1
while count <= 10 :
if count ==7:
pass
else:
print(count)
count = count + 1

break使用
#练习 通过break 实现1~10
count = 1
while True:
print(count)
if count == 10:
break
count = count + 1
print("结束")
continue使用


#字符串格式化
name = input("姓名:")#快速复制的方法:鼠标放到括号那里,然后ctrl+d
do = input("在做什么:")
template = "%s在教室,%s" %(name,do,)#do后面加,是为了表示结束
print(template)
%s----字符串
%d-----数据
%%-----%


#练习
name = input("姓名:")
age = input("年龄:")
job = input("职业:")
hobby = input("爱好:")
msg = ‘‘‘
--------info of Alex Lib----------
name :%s
age :%s
job :%s
hobby:%s
--------------end----------------‘‘‘
print(msg%(name,age,job,hobby))




小知识:
-int
-str
-bool
他们之间的转换
#字符串转数字 v1 = ‘666‘ v2 = int(v1) + 1 print(v2) #数字转bool v3 = 0 v4 = bool(v3) print(v4) #字符串转bool v5 = "alex" v6 = bool(v5)#因为v5是字符串,只有空串才会是false print(v6) v7 = "" v8 = bool(v7) print(v8)

---数字转字符串
---字符串转数字
---空字符串/0 转换为bool是False
#bool转str int v1 = False #大写F才是python关键字 v2 = str(v1) v3 = int(v1) print(v2) print(v3)

| 操作 | 含义 |
| x or y | if x is false,then y,else x |
| x and y | if x is false,then x,else y |
| not x | if x is false,then True,else False |
优先级关系:()>not>and>or,同一优先级从左往右算。
#对于or
value1 = 0 or 9 print(value1) value2 = 1 or 9 print(value2) #第一个值如果是转换为布尔值如果是真,则value=第一个值 #第一个值如果是转换为布尔值如果是假,则value=第二个值 value3 = 0 or "" print("---->",value3,"<----") value4 = 0 or 9 or 8 #遇到or多的时候,一个一个来,从左到右,从前到后 因为 0 or 9 值为9 print(value4) #所以相当于求 9 or 8 所以值为9
输出结果

#对于and
#如果第一个值转换为bool值为True,则value=后面的值
#如果第一个值转换为bool值为False,则value=第一个值
#如果遇到多个and ,从前往后,从左到右,依次进行
v1 =1 and 0
v2 = 1 and 9
v3 = 0 and 7
v4 = 0 and ""
v5 = 1 and 0 and 9
v6 = 1 and ""
v7 = "" and 1
v8 = "" and 0
v9 = 1 and 9 or 0 and 6 #没有括号时先算and 再算or(面试时,一般没有括号
print(v1)
print(v2)
print(v3)
print(v4)
print(v5)
print("---->",v6,"<----")
print("---->",v7,"<----")
print("---->",v8,"<----")
print(v9)
输出结果

#打印1~100的奇数
count = 1
while count <= 100:
if count%2 == 1:
print(count)
else:
pass
count = count + 1

val = 2**8 print(val) #输出为256 val = 9/2 print(val) #输出为4.5 val = 9//2 print(val) #输出为4
练习
#1~100所有数的和
count = 1
sum = 0
while count <= 100:
sum += count
count = count + 1
print(sum)
#输出为5050
unicode占4字节:分为--ecs2 占2个字节 ;ecs4 占4个字节
gbk--中文用2字节
gb2312--中文用2字节
utf-8 中文用3字节
单位转换
1B=8b 2**10=1KB 2**10KB=1MB 2**10MB=1GB 2**10GB=1TB 2**10TB=1PB 2**10PB=1EB 2**10EB=1ZB 2**10ZB=1YB 2**10YB=1NB 2**10NB=1DB
官网:https://git-scm.com/download/win
一直下一步就行
注册码云(保存代码)



提交到码云
(上传的目录名最好和刚刚创建的文件名相同)
在某个文件夹下完成作业,在此文件夹下 鼠标右键Git Bash Here
在黑框中输入命令:
git init 用于初始化,其实就是让git把当前所在文件夹管理起来
git add . 将当前文件夹所有的文件收集起来
git commit "第二天的作业"--这里的文字时随便写的 --这里指令的意思是:做个记录
第一次使用此命令需要先填写下面信息
git config --global user.email "you@example.com" git config --global user.name "Your Name"
git remote add origin https://gitee.com/NingNingD_520/demo.git

其实就是从创建的仓库那里学到的


上面在git的时候出现错误是因为如下所示,总之看码云上新建的库就知道后面的指令。

原文:https://www.cnblogs.com/glorious1314-151/p/15195276.html