Skip to content

Instantly share code, notes, and snippets.

@arlolra
Created December 9, 2010 22:31
Show Gist options
  • Save arlolra/735440 to your computer and use it in GitHub Desktop.
Save arlolra/735440 to your computer and use it in GitHub Desktop.
square with hole
#!/usr/bin/python
# square with hole
# for mike
import math
def user_inputs():
large = int(input('Enter an integer: '))
small = int(input('Now enter a smaller integer: '))
if large > small:
return [small, large]
else:
print "Try again!"
return user_inputs()
ui = user_inputs()
Small = ui[0]
Large = ui[1]
startHole = int(math.floor((Large - Small) / 2))
endHole = startHole + Small
for x in range(0, Large):
if x in range(startHole, endHole):
string = ''
for y in range(0, Large):
if y in range(startHole, endHole):
string += ' '
else:
string += '*'
print string
else:
print '*' * Large
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment