Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
bellcode
/
lesson8-1
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
48ddc136
authored
Jan 08, 2023
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
78042da0
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
12 deletions
.vscode/settings.json
diy1.py
quiz.py
.vscode/settings.json
0 → 100644
View file @
48ddc136
{
"python.formatting.provider"
:
"black"
}
\ No newline at end of file
diy1.py
View file @
48ddc136
dict
=
{
'可口可乐'
:
3
,
'旺仔牛奶'
:
4
,
'农夫山泉'
:
1
,
'辣条'
:
3
,
'巴西烤肉'
:
2
,
'果冻'
:
4
,
'乐事'
:
5
,
'奥利奥'
:
10
,
'巧克力'
:
6
}
k
=
input
(
"你想要买什么呀:"
)
if
k
in
dict
:
print
(
'叮咚,您的'
+
k
+
'需要支付'
+
str
(
dict
[
k
])
+
'元'
)
else
:
print
(
"抱歉,此商品暂时缺货"
)
quiz.py
View file @
48ddc136
# 直接运行以下代码,说说你的发现:
import
random
list_hero
=
[
'赵一'
,
30
,
'丁二'
,
37
,
'孙五'
,
52
,
'王猛'
,
89
,
'周亮'
,
98
]
dict_hero
=
{
'赵一'
:
30
,
'丁二'
:
37
,
'孙五'
:
52
,
'王猛'
:
89
,
'周亮'
:
98
}
message
=
"诺依,周末一起去看动漫展吧!"
print
(
len
(
list_hero
))
key
=
"kfnekfhirghejhg"
print
(
len
(
dict_hero
))
k_m
=
" "
\ No newline at end of file
c
=
input
(
"请输入:"
)
for
i
in
message
:
str1
=
i
str2
=
random
.
choice
(
key
)
str3
=
random
.
choice
(
key
)
text
=
str1
+
str2
+
str3
k_m
=
k_m
+
text
list_a
=
list
(
k_m
)
list_a
.
insert
(
random
.
randint
(
0
,
len
(
k_m
)),
c
)
c
=
" "
.
join
(
list_a
)
print
(
c
)
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