Python 3.4中+ + - 框的尺寸

时间:2016-01-02 07:20:47

标签: python dimensions

这是我的问题

创建一个程序,接受用户输入的数字。此数字定义正方形的尺寸,可以是任何正整数。输入1将输出:

    +--+
    +--+

while an input of 2 will output

    +--+--+
    +--+--+
    +--+--+

and an input of 3 will output

    +--+--+--+
    +--+--+--+
    +--+--+--+
    +--+--+--+

etc…Show outputs for user inputs of 1, 2, 3, and 4. 

不完全确定从哪里开始并希望得到一些建议,但我并不是在寻找一个完整的答案(毕竟,这是家庭作业)但是指向正确方向的东西会非常非常感谢。

2 个答案:

答案 0 :(得分:2)

考虑一下:

"--".join("++")

给你一行一盒:

+--+

要重复多行,您可以执行以下操作:

"--".join("+" * (some_count+1))

为此,你得到输出:

+--+        # 1
+--+--+     # 2
+--+--+--+  # 3
...

现在我们只需要重复多条垂直线。你可以考虑重复"\n".join,或者你可以使用for循环并打印多行。那就是你的工作!

答案 1 :(得分:0)

结束


string query = "Select * from VWpatientinfo";
    DataTable dataTableObject = new DataTable("Table Name");

完美适用于所有输出。感谢发表评论/回答的所有人!