我仍在学习 Python,因为我想向 11 岁的孩子(我是一名教师)教授该语言的基本概念。我们在基础方面做了一些工作,因此他们了解编程和将任务分解成块等的要点。随着新课程的推出,Python 是一种将在英国各地教授的语言,我不想教孩子们坏习惯。下面是我编写的一个小程序,是的,我知道这很糟糕,但任何关于改进的建议都将非常感激。
我仍在学习该语言的教程,所以请保持温柔!:o)
# This sets the condition of x for later use
x=0
# This is the main part of the program
def numtest():
print ("I am the multiplication machine")
print ("I can do amazing things!")
c = input ("Give me a number, a really big number!")
c=float(c)
print ("The number", int(c), "multiplied by itself equals",(int(c*c)))
print("I am Python 3. I am really cool at maths!")
if (c*c)>10000:
print ("Wow, you really did give me a big number!")
else:
print ("The number you gave me was a bit small though. I like bigger stuff than that!")
# This is the part of the program that causes it to run over and over again.
while x==0:
numtest()
again=input("Run again? y/n >>>")
if x=="y":
print("")
numtest()
else:
print("Goodbye")