Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
lesson7_4
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
9a99a2c5
authored
Apr 12, 2025
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
1c197d62
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
158 additions
and
20 deletions
1.py
diy4.py
1.py
0 → 100644
View file @
9a99a2c5
# # #1,输入与输出
# # b=input('输入一个数字')
# # b=int(b)
# # print(b+7)
# # #变量
# # a=1
# # a=a+10
# # print(a)
# #数据类型
# #字符串 增 '1'+'2'='12'
# #整型 1+1=2 3+3=6
# #可以转化
# # a=1
# # a=str(a)
# # b='2'
# # b=int(b)
# # print(b,type(b))
# # 算术运算符
# # +-*/ // %
# # print(10//3)
# # print(10%3)
# # a=input("输入一个三位数")
# # a=int(a)
# # g=a%10
# # print(g)
# #逻辑运算符 and or not
# #and or and-False or-True
# # print(1 or 2 and 4)
#turtle
# import turtle
# a=turtle.Pen()
# a.circle(50,steps=6)
# turtle.done()
# a=int(input("输入一个数字"))
# b=input("输入字符串,空格隔开")
# l1=b.split(" ")
# print(l1)
# l2=[]
# for i in l1:
# l2.append(i[:-1])
# def aaa(e):
# return len(e)
# l2.sort(reverse=False,key=aaa)
# for i in l2:
# print(i)
# a=[9,3,4,5,2,7]
# b=222
# lis=[]
# for i in range(len(a)):#0-5 a[i]
# for j in range(i+1,len(a)):
# lis.append(a[i]+a[j])
# print(lis)
# if b in lis:
# print(lis.count(10))
# else:
# print('没有')
# if len(a)%2==1:
# print(a[len(a)//2])
# else:
# print((a[len(a)//2]+a[len(a)//2-1])/2)
# print(a)
# a=[1,2,3,4,5,6,7,8,9,10]
# m=20
# # s=0
# # l=[]
# # for i in range(len(a)):
# # for j in range(i+1,len(a)):
# # s=a[i]+a[j]
# # l.append(s)
# # print(l)
# # print(l.count(m))
# # print(len('24'))
# 数据
# 单个 数字1,2,3
# 字符串 “1” “按不出a”
# a=1
# a='abc'
# 多个数据的存储
# 列表
# a=[1,2,3,'a','b']
# bbj=['性别','男','年龄','25','姓名','半半俊']
# 字典
aa
=
{
1
:
1
,
2
:
'1'
,
'a'
:
99
}
print
(
aa
)
a
=
1
a
=
3
diy4.py
View file @
9a99a2c5
import
random
# # # s='13900001234'
# # # t=s[0:3]
# 私钥
# # # w=s[-4:]
key
=
"abcdefgh使用编程实现位移替换加密,制作密码机关真是太好玩了哈哈!"
# # # print(t+'****'+w)
# 要加密语句
message
=
"诺依,周末一起去看动漫展吧!"
# a=int(input("输入一个数字,空格隔开"))
key_message
=
""
# s=input("输入字符串")
# 请使用私钥key,对message进行加密
# l1=s.split(' ')
for
i
in
range
(
len
(
message
)):
# new=[]
a
=
message
[
i
]
# for i in l1:
b
=
random
.
choice
(
key
)
# i=i[:-1]
c
=
random
.
choice
(
key
)
# new.append(i)
d
=
a
+
b
+
c
key_message
=
key_message
+
d
print
(
key_message
)
message1
=
list
(
key_message
)
# def funca(e):
message1
.
insert
(
random
.
randint
(
0
,
len
(
message1
)),
"¥
%
……&*$
%
_*^&
%
(
%
^"
)
# return len(e)
message2
=
""
.
join
(
message1
)
# new.sort(reverse=False,key=funca)
print
(
message2
)
# for i in new:
\ No newline at end of file
# print(i)
a
=
[
9
,
3
,
4
,
5
,
7
]
b
=
1
lis
=
[]
for
i
in
range
(
len
(
a
)):
for
j
in
range
(
i
+
1
,
len
(
a
)):
lis
.
append
(
a
[
i
]
+
a
[
j
])
lis
.
append
(
b
)
lis
.
sort
()
if
lis
.
count
(
b
)
>
1
:
print
(
b
)
else
:
print
(
lis
[
lis
.
index
(
b
)
-
1
])
# a=12345678
# a=str(a)
# j=0
# o=0
# for i in range(len(a)):
# if i%2==0:
# j+=int(a[i])
# else:
# o+=int(a[i])
# print(j,o,j*o)
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