Created
February 10, 2019 16:34
-
-
Save hikenshi/9eecc38a109543ff1a2436c3c50a2448 to your computer and use it in GitHub Desktop.
Exercise 3.3: Draws a grid. Sách Think Python
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 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