Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
lesson7_6
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
86334e53
authored
Nov 02, 2021
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
e3160ea5
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
145 additions
and
0 deletions
1.py
2-7-diy6.py
3.py
1.py
0 → 100644
View file @
86334e53
"""
list_test = ['一弦一柱思华年。
\n
','只是当时已惘然。
\n
'] # 将要默写的诗句放在列表里。
with open (r'h:
\
桌面
\
新建文本文档.txt','r') as f:
lines = f.readlines()
print(lines)
with open(r'h:
\
桌面
\
新建文本文档.txt','w') as new:
for line in lines:
if line in list_test: # 属于默写列表中的句子,将其替换成横线。
new.write('____________。
\n
')
else:
new.write(line)
# print(round(0.1+0.2,1) == 0.3)
import turtle
pen=turtle.Pen()
for i in range(6):
pen.forward(100)
pen.right(60)
turtle.done()
"""
year
=
int
(
input
(
"输入一个年份: "
))
if
(
year
%
4
)
==
0
:
if
(
year
%
100
)
==
0
:
if
(
year
%
400
)
==
0
:
print
(
str
(
year
)
+
"是闰年"
)
# 整百年能被400整除的是闰年
else
:
print
(
str
(
year
)
+
"不是闰年"
)
else
:
print
(
str
(
year
)
+
"是闰年"
)
# 非整百年能被4整除的为闰年
else
:
print
(
str
(
year
)
+
"不是闰年"
)
\ No newline at end of file
2-7-diy6.py
0 → 100644
View file @
86334e53
# import random
# # 私钥
# key = "abcdefgh使用python实现简单的位移替换加密,制作密码机关真是太好玩了哈哈哈!"
# # 要加密语句
# message = "诺依,周末一起去看动漫展吧!"
# # 最终加密后的语句
# key_message = ""
# # 干扰字符
# noise = "port:@#$%^&"
# for i in message:
# str1 = i
# str2 = random.choice(key)
# str3 = random.choice(key)
# text = str1+str2+str3
# key_message = key_message + text
# list_message = list(key_message)
# index = random.randint(0, len(key_message))
# list_message.insert(index, noise)
# result_message = "".join(list_message)
# print(result_message)
# def hcf(x, y):
# """该函数返回两个数的最大公约数"""
# # 获取最小值
# if x > y:
# smaller = y
# else:
# smaller = x
# for i in range(1,smaller + 1):
# if((x % i == 0) and (y % i == 0)):
# hcf = i
# return hcf
# # 用户输入两个数字
# num1 = int(input("输入第一个数字: "))
# num2 = int(input("输入第二个数字: "))
# print( num1,"和", num2,"的最大公约数为", hcf(num1, num2))
def
gongyue
(
a
,
b
):
"""
欧几里得算法----辗转相除法
:param a: 第一个数
:param b: 第二个数
:return: 最大公约数
"""
# 如果最终余数为0 公约数就计算出来了
a
=
int
(
input
(
"请输入一个数字:"
))
b
=
int
(
input
(
"请输入一个数字:"
))
while
(
b
!=
0
):
temp
=
a
%
b
a
=
b
b
=
temp
return
a
\ No newline at end of file
3.py
0 → 100644
View file @
86334e53
# import turtle
# pen=turtle.Pen()
# pen.forward(100)
# pen.pencolor("red")
# pen.pensize(2)
# pen.circle(100)
# pen.left(180)
# pen.forward(200)
# pen.left(180)
# pen.forward(100)
# pen.left(90)
# pen.forward(100)
# pen.left(180)
# pen.forward(200)
# turtle.done()
import
turtle
# turtle.hideturtle()
for
i
in
range
(
3
):
turtle
.
left
(
65
)
turtle
.
fillcolor
()
turtle
.
begin_fill
()
turtle
.
right
(
45
)
turtle
.
forward
(
100
)
turtle
.
right
(
80
)
turtle
.
forward
(
100
)
turtle
.
right
(
100
)
turtle
.
forward
(
100
)
turtle
.
right
(
80
)
turtle
.
forward
(
100
)
turtle
.
end_fill
()
turtle
.
done
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment