python Python练习 - 练习1(rrosinante)

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python Python练习 - 练习1(rrosinante)相关的知识,希望对你有一定的参考价值。

from datetime import datetime  # importing datetime module

# program that ask user their name and age, also show the years they will turn 100 years old
# Extra1 = ask user a number
# Extra2 = print message x times by Extra1 integer

# ask their name and age
name = input('Whats your name?: ')
age = int(input('how old are you?: '))

# declare current year
time = datetime.now()
currYear = time.year

year_until = 100 - age
year_of = currYear + year_until

message = "Hello " + name + " your age is " + str(age) + " and it will be " + str(year_of) + " for your 100th birthday\n"
print(message)

# Extra1 and Extra2
fun = int(input("Pick random number from 1 to 20: "))

print(fun * message)

以上是关于python Python练习 - 练习1(rrosinante)的主要内容,如果未能解决你的问题,请参考以下文章

Python输入输出练习,运算练习,turtle初步练习

Python练习题-1

Python输入输出练习,运算练习,turtle初步练习

Python练习

python练习1 ——菱形打印

python 基础 2.8 python练习题