如何用PYTHON计算出什么时候100岁

2025-05-10 01:49:34

1、打开JUPYTER NOTEBOOK,新建一个空白PY文档。

如何用PYTHON计算出什么时候100岁

3、name = input("Please input your name: ")age = int(input("Please input your age: "))但是要注意岁数要用整型,因为做算法是不能用字符串的。

如何用PYTHON计算出什么时候100岁

5、name = input("Please input your name: ")age = int(input("Please input your age: "))age_100 = str((100 - age) + 2018)print("The year that you will trun 100 years old is " + age_100 + " .")定义一下类型就可以了。

如何用PYTHON计算出什么时候100岁

7、import datetimenow = datetime.datetime.now()name = input("Please input your name: ")age = int(input("Please input your age: "))age_100 = str(now.year + 100 - age)print("The year that {} will turn 100 years old is ". format(name) + age_100 + " ." )可以把程式修改得更完美一些。

如何用PYTHON计算出什么时候100岁
声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
猜你喜欢