猫史档案馆


【Python作品分享】dictionary【教程贴】

用户:1X11X1查看:0 回复:1 评论:0 创建时间:2019-10-24T20:29:51


【作品展示】

center_image

 

【作品介绍】

this is the dictionary

 

【作品源代码】

dict_words = {}
while True:
    command = input('plese write what you want:1,create word 2,search your word 3,delent the word you create 4,finish the app')
    if (command == '1'):
        word = input('please write the word you want to create:')
        if (word in dict_words):
            print('you have create this word')
        else:
            word_meaning = input('please write your word meaning:')
            dict_words[word] = word_meaning
            print('now the word have:')
        print(dict_words)
    if (command == '2'):
        word = 'please write the word you want to search'
        if (word in dict_words):
            print('the word meaning is', dict_words[word])
    else:
        print('in this app dose not have this word')
    if (command == '3'):
        word = input('please write the word you want to delent')
        if (word in dict_words):
            del dict_words[word]
        else:
            print('in dictionary does not have this word')
    if (command == '4'):
        print('thank you to use this app make by apple')
        break

 

【提示】

部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:

https://python.codemao.cn


回复

上一页1 页 / 共 1下一页
QBZ_QBZ_

# encoding:utf-8
import time

class Dog():
    def __init__(self,color,name,eat,old):
        self.eat = eat
        self.name = name 
        self.color = color
        self.old = old
    def cry(self):
        print("汪汪汪~")
    def run(self):
        print("我会跑~")    
    def spoke(self):
        print("我来啦")

# 绿茶
lvcha = Dog(color = "灰色", name = "绿茶",eat = "喵",old = "2")
lvcha.cry()
lvcha.spoke()
lvcha.run()
print("我叫{},我{}岁,我的颜色是{},我喜欢吃{}".format(lvcha.name,lvcha.old,lvcha.color,lvcha.eat))

print("----------------------------------------------------------------------")
time.sleep(1.5)

# 胖虎
panghu = Dog(color="橘色", name="胖虎", eat="骨头", old="3")
panghu.cry()
panghu.spoke()
panghu.run()
print("我叫{},我{}岁,我的颜色是{},我喜欢吃{}".format(panghu.name, panghu.old, panghu.color, panghu.eat))
print("-----------------------------------------------------------------------")

点赞0


评论