diff options
| author | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2021-04-16 06:01:57 +0100 |
|---|---|---|
| committer | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2021-04-16 06:01:57 +0100 |
| commit | f8d3372c5ba5aca839049c0830fec184188d5124 (patch) | |
| tree | bf992af23da1901889ea44c609a2efb903d367a2 /challenge-108/colin-crain/python | |
| parent | 3b823f0e8b1e65aff431a8b4499b7860e9799f76 (diff) | |
| download | perlweeklychallenge-club-f8d3372c5ba5aca839049c0830fec184188d5124.tar.gz perlweeklychallenge-club-f8d3372c5ba5aca839049c0830fec184188d5124.tar.bz2 perlweeklychallenge-club-f8d3372c5ba5aca839049c0830fec184188d5124.zip | |
- Added solutions by Colin Crain.
Diffstat (limited to 'challenge-108/colin-crain/python')
| -rw-r--r-- | challenge-108/colin-crain/python/ch-1.py | 16 | ||||
| -rw-r--r-- | challenge-108/colin-crain/python/ch-2.py | 14 |
2 files changed, 30 insertions, 0 deletions
diff --git a/challenge-108/colin-crain/python/ch-1.py b/challenge-108/colin-crain/python/ch-1.py new file mode 100644 index 0000000000..9d0e760eb7 --- /dev/null +++ b/challenge-108/colin-crain/python/ch-1.py @@ -0,0 +1,16 @@ +foo = 42 +loc_foo = hex(id(foo)) + +print( "the variable 'foo' is located at:", loc_foo ) + +bar = 42 +loc_bar = hex(id(bar)) + +print( "the variable 'bar' is located at:", loc_bar ) +print( "bar equals foo :", bar == foo ) +print( "bar is the same object as foo :", bar is foo) + +if loc_foo == loc_bar: + print( "the value", foo, "is interned") +else: + print( "the value", foo, "is not interned") diff --git a/challenge-108/colin-crain/python/ch-2.py b/challenge-108/colin-crain/python/ch-2.py new file mode 100644 index 0000000000..0134e5723d --- /dev/null +++ b/challenge-108/colin-crain/python/ch-2.py @@ -0,0 +1,14 @@ +values = 10 +tri = [[0 for x in range(x+1)] for x in range(values)] + +tri[0][0] = 1 + +for row in range(1,len(tri)): + tri[row][0] = tri[row-1][-1] + for i in range(1,row+1): + tri[row][i] = tri[row][i-1] + tri[row-1][i-1] + +for row in tri: + for elem in row: + print(elem, end=" ") + print() |
