我熟悉使用%.2f为浮点数设置两个小数位的约定但是以任何方式可以将数字更改为变量,以便用户可以说明显示的小数位数?
我还在学习Python,因为我想向十一岁的孩子讲授这门语言的基本概念(我是一名教师).我们在基础方面做了一些工作,因此他们了解编程的基本要素,并将任务分解成块等.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 …Run Code Online (Sandbox Code Playgroud)