-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbowtie.py
More file actions
executable file
·50 lines (39 loc) · 945 Bytes
/
bowtie.py
File metadata and controls
executable file
·50 lines (39 loc) · 945 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env python3
# Your program should take as input the height H of the bow tie, where H is an odd positive integer greater than or equal to 5.
# A bow tie with H rows (and 2H columns) should then be printed using the pattern shown below. You may assume that all input data will be valid.
# input = 5
# * *
# *** ***
# **********
# *** ***
# * *
# input = 7
# * *
# *** ***
# ***** *****
# **************
# ***** *****
# *** ***
# * *
from __future__ import print_function
h = 7
w = 2*h
half = (h-1)//2
print ()
x = 1
for n in range(0,half):
print ('*' * x, end='')
spaces = w - 2*x
print (' ' * spaces, end='')
print ('*' * x)
x += 2
print ('*' * w, end ='')
print ()
x = (w-4)//2
for n in range(0,half):
print ('*' * x, end='')
spaces = w - 2*x
print (' ' * spaces, end='')
print ('*' * x)
x -= 2
print()