Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
bellcode
/
lesson8-3
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
1419ab50
authored
Dec 28, 2024
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
845c1255
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
7 deletions
quiz.py
quiz.py
View file @
1419ab50
dict
=
{
'可口可乐'
:
3
,
'旺仔牛奶'
:
4
,
'农夫山泉'
:
1
,
'辣条'
:
3
,
'巴西烤肉'
:
2
,
'果冻'
:
4
,
}
def
print_tree
(
height
):
k
=
input
(
'你想买什么?'
)
for
i
in
range
(
height
):
if
k
in
dict
:
print
(
' '
*
(
height
-
i
-
1
)
+
'*'
*
(
2
*
i
+
1
))
print
(
'叮咚~您的''+k+'
需要支付
'+str(dict[k])+'
元
~
')
print
(
' '
*
(
height
-
1
)
+
'|'
)
else:
print('
神奇百货暂未有你想要的物品,敬请期待
~
')
def
print_decorted_tree
(
heght
,
decorations
=
5
):
\ No newline at end of file
print_tree
(
height
)
print
(
' '
*
(
height
-
1
)
+
'*'
)
for
i
in
range
(
decorations
):
level
=
i
%
(
height
-
1
)
+
1
pos
=
(
level
*
2
-
1
)
//
2
+
i
%
2
print
(
' '
*
(
height
-
level
-
1
)
+
'*'
*
(
pos
)
+
'0'
+
'*'
)
if
_name_
==
"_main_"
:
height
=
5
decorations
=
10
print_decroratted_tree
(
height
,
decorations
)
\ No newline at end of file
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