【发布时间】:2018-08-24 00:05:02
【问题描述】:
我在 Re: 条件语句类中遇到的一个问题遇到了很多麻烦。
我很难理解如何让两个变量("year" 和 "s")能够进入一个 {}。
我必须显示一个人的年龄(以他们的出生年份为准):
计算出用户的出生年份并显示适当的 下方留言
<FirstName>, it is now <CurrentYear>, you are <Age> year old and so you were born in <YearOfBirth>. <FirstName>, it is now <CurrentYear>, you are <Age> years old and so you were born in <YearOfBirth>.上面使用的信息在语法上必须符合年龄。
<FirstName>是用户的名字。<CurrentYear>是当前年份<Age>是用户的年龄。<YearOfBirth>是用户的出生年份。
以及他们给出的一些例子:
Please enter your first name: Jane Hi Jane, please enter your age in years: 1 Jane, it is now 2018, you are 1 year old and so you were born in 2017.
和
Please enter your first name: Elaine Hi Elaine, please enter your age in years: 22 Elaine, it is now 2018, you are 22 years old and so you were born in 1996.
我必须使用以下字符串:
"{}, it is now {}, you are {} {} old and so you were born in {}." "year" "s"
【问题讨论】:
-
我投票决定将此问题作为离题结束,因为 SO 不是代码编写或教程服务。请展示你的努力
-
@EdChum 引用的
{}指的是字符串格式变量,因此第一次谷歌点击是无用的。我想说的是保持问题开放,毕竟他们并没有要求我们编写代码。 -
话虽如此,@sacker,这个问题包含很多说明。尽量在每个帖子中保留一个可回答的问题,并且只提供与此完全相关的信息。
-
@Arne 很公平,但这个问题仍然过于宽泛,因为它需要帮助来理解他们的任务,所以它甚至还没有达到编码阶段,编程是 SO 的主要推动力
-
我已经大大减少了你的问题文本。请注意这是如何编辑的;我把你的问题放在首位,所以阅读这篇文章的人知道要寻找什么。我从作业文本中删除了与您的实际问题无关的所有内容。尝试在以后的问题中做同样的事情。
标签: python boolean conditional