Skip to content

Commit

Permalink
第一次commit,添加课时1~33知识点及代码
Browse files Browse the repository at this point in the history
  • Loading branch information
amusi committed Nov 11, 2017
1 parent 834476f commit 4c4c06c
Show file tree
Hide file tree
Showing 84 changed files with 1,943 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

677 changes: 677 additions & 0 deletions .idea/workspace.xml

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions .idea/零基础入门学python.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added .~础入门学习Python.docx
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Oct 18 19:35:54 2017
@author: amusi
"""

# 密码安全性检查代码
#
# 低级密码要求:
# 1. 密码由单纯的数字或字母组成
# 2. 密码长度小于等于8位
#
# 中级密码要求:
# 1. 密码必须由数字、字母或特殊字符(仅限:~!@#$%^&*()_=-/,.?<>;:[]{}|\)任意两种组合
# 2. 密码只能由数字开头
# 3. 密码长度不能低于8位
#
# 高级密码要求:
# 1. 密码必须由数字、字母及特殊字符(仅限:~!@#$%^&*()_=-/,.?<>;:[]{}|\)三种组合
# 2. 密码只能由字母开头
# 3. 密码长度不能低于16位

str1 = input("please input passward: ")
if str1.isalnum() and len(str1) <= 8:
print("低级密码")
elif str1.isalnum() and str1[0].isdigit() and len(str1) >= 8:
print("中级密码")
elif str1.isalnum() and str1[0].isalpha() and len(str1) >= 16:
print("高级密码")
else:
print("Not sure!")
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sun Oct 22 17:35:33 2017
@author: amusi
"""

def discount(price, rate):
final_price = price * rate
return final_price

old_price = float(input("请输入原价: "))
rate = float(input("请输入折扣率: "))
new_price = discount(old_price, rate)
print("打折后价格为: ", new_price)
15 changes: 15 additions & 0 deletions 课时19 函数: 我的地盘我做主/Program001_Review1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sun Oct 22 19:01:10 2017
@author: amusi
"""

def fun(var):
var = 1314
print(var, end = "")

var = 520
fun(var)
print(var)
24 changes: 24 additions & 0 deletions 课时19 函数: 我的地盘我做主/Program001_Review2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sun Oct 22 19:02:57 2017
@author: amusi
"""

var = " Hi "

def fun1():
global var
var = " Baby "
return fun2(var)

def fun2(var):
var += "I love you"
fun3(var)
return var

def fun3(var):
var = " Amusi "

print(fun1())
24 changes: 24 additions & 0 deletions 课时19 函数: 我的地盘我做主/Program001_Review3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sun Oct 22 19:11:09 2017
@author: amusi
"""
# 编写一个函数,判断传入的字符串参数是否为“回文联”
# (回文联即用回文形式写的对联,即可顺读,也可倒读,例如:上海自来水来自海上)

def palindrome(string):
length = len(string)
string2 = string
flag = 1
for i in range(length // 2):
if string[i] != string2[length -(i+1)]:
flag = 0
break
if flag == 1:
print("输入的字符串是回文联!")
else:
print("输入的字符串不是回文联!")
palindrome("上海自来水来自海上")
palindrome("我爱你因为你爱我")
8 changes: 8 additions & 0 deletions 课时19 函数: 我的地盘我做主/Program001_Review4.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sun Oct 22 19:11:23 2017
@author: amusi
"""

15 changes: 15 additions & 0 deletions 课时2 用Python设计第一个游戏/Program0.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Oct 9 18:36:38 2017
@author: amusi
"""
print(".............Amusi...........")
temp = input("Can you guess which number I am thinking?")
guess = int(temp)
if guess == 8:
print("Congratulations!")
else:
print("Sorry")
print("Game Over...")
9 changes: 9 additions & 0 deletions 课时2 用Python设计第一个游戏/Program1_BIF.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Oct 9 19:24:38 2017
@author: amusi
"""
print(dir(__builtins__))
print(help(input))
5 changes: 5 additions & 0 deletions 课时2 用Python设计第一个游戏/Program2_Hello.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env Python3
# -*- coding: utf-8 -*-

name = input("请输入您的姓名: ")
print("您好, " + name + "!")
9 changes: 9 additions & 0 deletions 课时2 用Python设计第一个游戏/Program3_calc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env Python3
# -*- coding: utf-8 -*-

numsStr = input("请您输入0~100之间的数字: ")
nums = int(numsStr)
if 0 <= nums <= 100:
print("厉害了, Word哥")
else:
print("你走吧~")
25 changes: 25 additions & 0 deletions 课时24 递归汉诺塔/Program000_huiwen.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sat Oct 28 20:10:52 2017
@author: amusi
"""

# 使用递归的方式求解“回文字符串”
def is_palindrome(n, start, end):
if start > end:
return 1
else:
#return is_palindrome(n, start+1, end-1) if n[start] == n[end] else 0
if n[start] == n[end]:
return is_palindrome(n, start+1, end-1)
else:
return 0

string = input("请输入一串字符串: ")
length = len(string)-1
if is_palindrome(string, 0, length):
print("%s 是回文字符串!" % string)
else:
print("%s 不是回文字符串!" % string)
21 changes: 21 additions & 0 deletions 课时24 递归汉诺塔/Program000_review2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sat Oct 28 20:18:58 2017
@author: amusi
"""

"""
有5个人坐在一起,问第5个人多少岁?他说比第4个大2岁。问第4个人岁数,他说比第3个人大2岁。
问第3个人,又说比第2个人大2岁。问第2个人,说比第一个人大2岁。最后问第一个人,他说是10岁。请问第5个人多少岁?
"""

def age(n):
if n == 1:
return 10
else:

return 2 + age(n-1)

print("第5个人 %d 岁" % age(5))
25 changes: 25 additions & 0 deletions 课时24 递归汉诺塔/Program000_汉诺塔.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sat Oct 28 16:29:57 2017
@author: amusi
"""

'''
汉诺塔:汉诺塔(又称河内塔)问题是源于印度一个古老传说的益智玩具。
大梵天创造世界的时候做了三根金刚石柱子,在一根柱子上从下往上按照大小顺序摞着64片黄金圆盘。
大梵天命令婆罗门把圆盘从下面开始按大小顺序重新摆放在另一根柱子上。并且规定,在小圆盘上不能放大圆盘,在三根柱子之间一次只能移动一个圆盘。
'''
def hanoi(n, x, y, z):
if n == 1:
print(x, " --> ", z)
else:
hanoi(n-1, x, z, y) # 将前n-1个盘从移动到y上
print(x, " -->", z) # 将最底下的最后一个盘子从x移动到z上
hanoi(n-1, y, x, z) # 将y上的n-1盒子移动到z上

n = int(input("请输入hanoi层数: "))
hanoi(n, "x", "y", "z")


47 changes: 47 additions & 0 deletions 课时26 字典: 当索引不好用时/Program000_review.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Oct 30 23:16:57 2017
@author: amusi
"""

def PrintInfo():
print("""|--- 欢迎进入通讯录程序 ---|
|--- 1:查询联系人资料 ---|
|--- 2:插入新的联系人 ---|
|--- 3:删除已有联系人 ---|
|--- 4:退出通讯录程序 ---|
""")

def Process(n):
contacts = dict()
while 1:
if n == 1:
nameTemp = input("请输入联系人姓名: ")
if nameTemp in contacts: # 注意写法
print(nameTemp + ": " + contacts[nameTemp])
else:
print("您输入的姓名不在通讯录中!")
if n == 2:
nameTemp = input("请输入联系人姓名: ")
if nameTemp in contacts:
print("您输入的姓名在通讯录中已经存在-->>", end ="") # 不换行
print(nameTemp + ": " + contacts[nameTemp])
else:
contacts[nameTemp] = input("请输入用户联系电话: ")
if n == 3:
nameTemp = input("请输入联系人姓名: ")
if nameTemp in contacts:
del(contacts[nameTemp]) # 注意写法,也可以使用dict.pop()
else:
print("您输入的联系人不存在...")
if n == 4:
print("|--- 感谢使用通讯录程序 ---|")
break;
n = int(input("\n请输入相关的指令代码: "))


PrintInfo()
num = int(input("请输入相关的指令代码: "))
Process(num)
Empty file.
3 changes: 3 additions & 0 deletions 课时29 文件: 一个任务/amusi.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
加油,相信自己!
2018年,事业与爱情双丰收!
Fighting!
3 changes: 3 additions & 0 deletions 课时29 文件: 一个任务/boy_1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
干嘛呢?
吃饭了么?
我呀,吃得面条
3 changes: 3 additions & 0 deletions 课时29 文件: 一个任务/boy_2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
下班了么
走到哪啦?
我呀,还在加班工作呢
3 changes: 3 additions & 0 deletions 课时29 文件: 一个任务/boy_3.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
哈哈,感觉像是哈士奇
昨天买的哈密瓜吃完了么?
走,那个有个水果店,去买点水果
3 changes: 3 additions & 0 deletions 课时29 文件: 一个任务/girl_1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
做教案
恩,刚吃过,吃的饺子,你呢?
嘿嘿,很赞
2 changes: 2 additions & 0 deletions 课时29 文件: 一个任务/girl_2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
恩,刚下班了
南京路,准备坐地铁啦,你在干嘛呢?
3 changes: 3 additions & 0 deletions 课时29 文件: 一个任务/girl_3.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
你看那个狗狗,好萌啊!
应该不是,我看像牧羊犬
恩,吃完啦
20 changes: 20 additions & 0 deletions 课时29 文件: 一个任务/record.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Amusi:干嘛呢?
Lucy:做教案
Amusi:吃饭了么?
Lucy:恩,刚吃过,吃的饺子,你呢?
Amusi:我呀,吃得面条
Lucy:嘿嘿,很赞
===============================
Amusi:下班了么
Lucy:恩,刚下班了
Amusi:走到哪啦?
Lucy:南京路,准备坐地铁啦,你在干嘛呢?
Amusi:我呀,还在加班工作呢
===============================
Lucy:你看那个狗狗,好萌啊!
Amusi:哈哈,感觉像是哈士奇
Lucy:应该不是,我看像牧羊犬
Amusi:昨天买的哈密瓜吃完了么?
Lucy:恩,吃完啦
Amusi:走,那个有个水果店,去买点水果
===============================
20 changes: 20 additions & 0 deletions 课时29 文件: 一个任务/record1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Amusi:干嘛呢?
Lucy:做教案
Amusi:吃饭了么?
Lucy:恩,刚吃过,吃的饺子,你呢?
Amusi:我呀,吃得面条
Lucy:嘿嘿,很赞
===============================
Amusi:下班了么
Lucy:恩,刚下班了
Amusi:走到哪啦?
Lucy:南京路,准备坐地铁啦,你在干嘛呢?
Amusi:我呀,还在加班工作呢
===============================
Lucy:你看那个狗狗,好萌啊!
Amusi:哈哈,感觉像是哈士奇
Lucy:应该不是,我看像牧羊犬
Amusi:昨天买的哈密瓜吃完了么?
Lucy:恩,吃完啦
Amusi:走,那个有个水果店,去买点水果
===============================
Loading

0 comments on commit 4c4c06c

Please sign in to comment.