Created
May 4, 2013 10:20
-
-
Save kanghyojun/5517066 to your computer and use it in GitHub Desktop.
Draw a circle http://www.synapsoft.co.kr/jsp/recruit/recruitment.jsp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def draw_circle(r): | |
space_num = r * 2 + 1 | |
def circle(x, y, radius): | |
radius_point = (x - radius)**2 + (y - radius) **2 | |
radius_square = radius**2 | |
correct_value = 1 | |
if radius <= 3: | |
correct_value = 0.7 | |
return radius_square * correct_value <= radius_point <= radius_square * 1.3 | |
for h in range(0, space_num): | |
for w in range(0, space_num): | |
if circle(w, h, r): | |
print("@", end="") | |
else: | |
print(" ", end="") | |
print("") | |
if __name__ == "__main__": | |
for x in range(1, 14): | |
print("Drawing {0} radius circle".format(x)) | |
draw_circle(x) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment