Differences between revisions 1 and 7 (spanning 6 versions)
Revision 1 as of 2018-10-14 22:13:33
Size: 441
Comment:
Revision 7 as of 2018-10-29 05:31:46
Size: 898
Comment:
Deletions are marked like this. Additions are marked like this.
Line 5: Line 5:
#acl AdminGroup:read,write,delete,revert,admin TadashiIijima:read,write,delete,revert,admin IijimaStaffGroup: IijimaGroup: IijimaObogGroup: GuestGroup: Known: All: #acl AdminGroup:read,write,delete,revert,admin TadashiIijima:read,write,delete,revert,admin IijimaStaffGroup: IijimaGroup: IijimaObogGroup: GuestGroup: Known: All:read
Line 7: Line 7:
[ <<Action(edit)>> ]
Line 10: Line 11:

{{{#!highlight python
{{{#!highlight python numbers=off
Line 14: Line 14:
    for i in range( start, end ):     for i in range( start, end + 1 ):
Line 18: Line 18:

 * 【別解】
  * 以下の部分は,当然ですが,べき乗で表現することもできます.

{{{#!highlight python numbers=off
# ----- 計算と結果の表示 ----
x = 1
for i in range( 5 ):
    x *= 10
    print( sum_of_range( 1, x ) )
}}}

{{{#!highlight python numbers=off
# ----- 計算と結果の表示 ----
for i in range( 1, 5 ):
    print( sum_of_range( 1, 10 ** i ) )
}}}

[ edit ]

  • 解答は基本的に,下記 5 行の関数です.

def sum_of_range( start, end ):
    sum = 0
    for i in range( start, end + 1 ):
        sum += i
    return( sum )
  • 【別解】
    • 以下の部分は,当然ですが,べき乗で表現することもできます.

# ----- 計算と結果の表示 ----
x = 1
for i in range( 5 ):
    x *= 10
    print( sum_of_range( 1, x ) )

# ----- 計算と結果の表示 ----
for i in range( 1, 5 ):
    print( sum_of_range( 1, 10 ** i ) )

SoftEng: Python/Prog/Practice/Extended/02/EP_001a/Digest (last edited 2019-10-16 14:41:11 by TadashiIijima)