MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / pretty_print

Function pretty_print

other/magicdiamondpattern.py:55–73  ·  view source on GitHub ↗

Print a complete diamond pattern with '*' characters. Args: n (int): Size of the pattern. Examples: >>> pretty_print(0) ' ... .... nothing printing :(' >>> pretty_print(3) ' * \\n * * \\n* * * \\n* * * \\n * * \\n

(n)

Source from the content-addressed store, hash-verified

53
54# Function to print complete diamond pattern of "*"
55def pretty_print(n):
56 """
57 Print a complete diamond pattern with '*' characters.
58
59 Args:
60 n (int): Size of the pattern.
61
62 Examples:
63 >>> pretty_print(0)
64 ' ... .... nothing printing :('
65
66 >>> pretty_print(3)
67 ' * \\n * * \\n* * * \\n* * * \\n * * \\n * \\n '
68 """
69 if n <= 0:
70 return " ... .... nothing printing :("
71 upper_half = floyd(n) # upper half
72 lower_half = reverse_floyd(n) # lower half
73 return upper_half + lower_half
74
75
76if __name__ == "__main__":

Callers

nothing calls this directly

Calls 2

floydFunction · 0.85
reverse_floydFunction · 0.85

Tested by

no test coverage detected