Welcome, guest | Sign In | My Account | Store | Cart

Just a little holiday tree, would make a good exercise for beginning Python programmers.

Python, 17 lines
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
# Happy Holidays!
# with height = 5:
#     *
#    ***
#   *****
#  *******
# *********
#     |
# Dependency: Python 3.3

height = 5

stars = 1
for i in range(height):
    print((' ' * (height - i)) + ('*' * stars))
    stars += 2
print((' ' * height) + '|')
Created by Bill Pickett on Mon, 2 Dec 2013 (CC0)
Python recipes (4591)
Bill Pickett's recipes (3)

Required Modules

  • (none specified)

Other Information and Tasks