Skip to content

Instantly share code, notes, and snippets.

@hikenshi
Created February 10, 2019 16:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hikenshi/9eecc38a109543ff1a2436c3c50a2448 to your computer and use it in GitHub Desktop.
Save hikenshi/9eecc38a109543ff1a2436c3c50a2448 to your computer and use it in GitHub Desktop.
Exercise 3.3: Draws a grid. Sách Think Python
def print_arg(s):
print(s, end=' ')
def print_four(f,s):
for i in range(0,4):
f(s)
def so_o_doc(h,f,s):
for i in range(0,int(h)):
print_arg(f)
print_four(print_arg,s)
print_arg(f)
print('\n')
def do_four(f,h,a,b):
for i in range(0,4):
f(h,a,b)
def draw_grid(h,a,b,c,d):
so_o_doc(h,a,b)
do_four(so_o,h,c,d)
def ve_ovuong(SoCot,SoHang,Kyhieu1,KyHieu2,KyHieu3,KyHieu4):
for i in range(0,int(SoHang)):
draw_grid(SoCot,Kyhieu1,KyHieu2,KyHieu3,KyHieu4)
so_o_doc(SoCot,Kyhieu1,KyHieu2)
SoCot = input("Nhap so cot: ")
SoHang = input("Nhap so hang: ")
Kyhieu1 = input("Nhap ky hieu 1: ")
KyHieu2 = input("Nhap ky hieu 2: ")
KyHieu3 = input("Nhap ky hieu 3: ")
KyHieu4 = input("Nhap ky hieu 4: ")
ve_ovuong(SoCot,SoHang,Kyhieu1,KyHieu2,KyHieu3,KyHieu4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment