您将如何使用python创建Math应用?

时间:2019-07-22 21:59:53

标签: python python-3.x python-2.7

我是编程界的新手,我需要使用任何编程语言创建一个应用程序/ Web应用程序。当我发现Python更容易时,我正在努力从哪里开始,所以任何建议都是不错的。 我现在主要在做一些基础工作,例如:

input random
name = input("What's your Name: ")
print("Hello, " + name + "!") 
x = 10
y = 12
print(x + y) 

上面的代码只是一个示例示例。我想创建一个针对不同年龄的不同问题的应用程序,但是我不知道如何将10岁和12岁的问题分开。任何建议性编码都会有所帮助。我已经学习了大多数教程,但是我无法将代码链接在一起。谢谢!

1 个答案:

答案 0 :(得分:0)

我希望这是您所期望的:

#take age as an input and parse it to an integer
age = int(input('Age: '))

#if the person is older than 15 but younger than 20 ask a question...
if(age < 20 and age >15):
    question to ask
#if the person is or is younger than 15 but older than 10...
elif(age <= 15 and age >10):
    question to ask
#if the person is  10...
elif(age==10):
    question to ask
#if a person doesn't fit in any of the mentioned area's
else:
    question to ask