python Python SE03#3和
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python Python SE03#3和相关的知识,希望对你有一定的参考价值。
#Correct code
#.ipynb
def asker(question):
msg1 = 'Question unspecified'
msg2= 'Type unknown'
final = 'Answer unknown'
if question.lower()=='name':
msg1 = input('What is your name? ')
msg2 = 'name'
elif question.lower()=='age':
msg1 = input('How old are you? ')
msg2 = 'age'
elif question.lower()=='city':
msg1 = input('What is your city?')
msg2 = 'city'
elif question.lower()=='country':
msg1 = input('What is your country? ')
msg2 = 'country'
#userInput = {}
userInput = {
'type': msg2,
'answer' : msg1
}
return userInput
def greeting(name_data, age_data, country_data, city_data):
name_data = asker('name')
age_data = asker('age')
country_data = asker('country')
city_data = asker('city')
msg=("Hello, " + name_data['answer'] +
"\nI see you live in " + city_data['answer'] + ", " + country_data['answer'] + "."
"\nYou are currently " + age_data['answer'] + " years old."
)
return msg
name_data = {}
age_data = {}
country_data = {}
city_data = {}
msg = greeting(name_data, age_data, country_data, city_data)
print(msg)
以上是关于python Python SE03#3和的主要内容,如果未能解决你的问题,请参考以下文章
python--集合增删改 交集 差集 并集 反交集 子集和超集
03python面向对象编程1
dict和set之间的区别(python)
python3学习之set集合
python2.7报错Non-ASCII character 'xe5' in file knn.py on line 3, but no encoding declared; se(
python set集合的用法