我对使用Python编程(以及一般的编码)还不太熟悉,我想得到一些关于一个小型“helloworld”项目的帮助。
以下是我目前的进展:
#meet and greet program in python
print('Hello, nice to meet you')
username = input('Please enter your name: ')
print('Nice to meet you', username)
byear = input('What year were you born? :')
print('So you were born in the year', byear, '?' )
information = input('Is this information is correct? :')
if information == ('Yes') :
print('Ok')
currentyr = input('Please enter the current year:')
print('So that means you are', currentyr - byear,'years old. Right?')
我遇到的问题是最后一行,我想通过从当前年份中减去用户的出生年份(通过输入)来找到用户当前的大概年龄(也通过输入-不知道如何导入当前年份详细信息)。
这可以在最后一行的中间找到:
,当前年-年
如果有人能给我解释一下,我如何从另一个输入变量(byear)中减去这个输入变量(currentyr),从而得到用户的大概年龄。
提前谢谢。
目前没有回答
相关问题 更多 >
编程相关推荐