Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
bellcode
/
lesson8-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
0cd59831
authored
Jan 04, 2021
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
68714a28
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
9 deletions
diy.py
diy.py
View file @
0cd59831
food
=
{
"可口可乐"
:
4
,
"辣条"
:
3
,
"薯片"
:
12
}
#1.输入名字和价格
#2.判断商品是否在字典中
#3.判断新商品和原本字典中的商品哪个更便宜
#4.便宜就修改字典的值
#5.否则就输出太贵了
#6.如果不在就添加进字典中,并输出
\ No newline at end of file
#1.通过input输入我们想要的商品 赋值给一个变量f 键
f
=
input
(
'请输入商品名'
)
#2.判断你的售货机里是否有这件商品 (判断 f 在 food)
if
f
in
food
:
print
(
f
+
str
(
food
[
f
]))
#3.在的话,就输出他的价格
else
:
print
(
'无货'
)
#4.否则就输出没有货
\ 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