小编Kir*_*ers的帖子

可以在Python中使用变量来定义小数位

我熟悉使用%.2f为浮点数设置两个小数位的约定但是以任何方式可以将数字更改为变量,以便用户可以说明显示的小数位数?

python floating-point

13
推荐指数
3
解决办法
6312
查看次数

请编写我的示例Python程序代码

我还在学习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)

python loops while-loop

7
推荐指数
1
解决办法
5万
查看次数

标签 统计

python ×2

floating-point ×1

loops ×1

while-loop ×1