显示星号曲棍球棒
display asterisk hockey stick
我确信这是一个简单的解决方案,但我遗漏了一些细节,考虑到这是我的第一个编程,这并不奇怪 class。我无法正确使用此功能,我的说明如下。
"""
指示:
您的项目将实现许多功能。每个功能
显示不同的形状。您的代码必须只使用以下功能
在项目代码中找到的,可以向控制台显示任何内容。 (你
不得在您正在完成的功能中使用打印语句。)
star() 显示一个没有新行的“*”字符
fill() 显示一个没有新行的“#”字符
space() 显示没有新行的 ' ' 字符
newline() 显示一个新行
每个函数都在这个底部的主代码中调用
项目文件。函数包含您需要匹配的样本输出。
"""
# ================================================= ========================
# 接下来的四个函数不要改。它们应该用于
# 你完成的功能。
# ================================================= ========================
def star():
""" Display a star without the normal new line """
print('*', end='')
def fill():
""" Display a fill character without the normal new line """
print('#', end='')
def space():
""" Display a space without the normal new line """
print(' ', end='')
def newline():
""" Display a new line """
print()
def displayTriangle(n):
for row in range(1, n + 1):
for col in range(row):
star()
newline()
newline()
def hockeyStick(handleLen, bladeLen):
""" Display a hockey stick where the handle is of length handleLen
and the blade is of length bladeLen.
- This example has handleLen = 6, bladeLen = 7
*
*
*
*
*
*
*******
"""
print('Hockey stick of size', handleLen, 'and', bladeLen)
曲棍球棒图案输出应该能够格式化为 "handleLen" 和 "bladeLen" 中的任何格式。我一直在尝试使用由 space 组成的三角形并在末尾添加一个星号,但我无法使用 "handleLen" 和 "bladeLen"。任何帮助表示赞赏。
def hockeyStick(handleLen, bladeLen):
""" Display a hockey stick where the handle is of length handleLen
and the blade is of length bladeLen.
- This example has handleLen = 6, bladeLen = 7
*
*
*
*
*
*
*******
"""
print('Hockey stick of size', handleLen, 'and', bladeLen)
for row in range(1, handleLen + 1):
for col in range(row-1):
space()
star()
newline()
for col in range(handleLen):
space()
for col in range(bladeLen):
star()
我确信这是一个简单的解决方案,但我遗漏了一些细节,考虑到这是我的第一个编程,这并不奇怪 class。我无法正确使用此功能,我的说明如下。 """ 指示: 您的项目将实现许多功能。每个功能 显示不同的形状。您的代码必须只使用以下功能 在项目代码中找到的,可以向控制台显示任何内容。 (你 不得在您正在完成的功能中使用打印语句。) star() 显示一个没有新行的“*”字符 fill() 显示一个没有新行的“#”字符 space() 显示没有新行的 ' ' 字符 newline() 显示一个新行 每个函数都在这个底部的主代码中调用 项目文件。函数包含您需要匹配的样本输出。 """ # ================================================= ======================== # 接下来的四个函数不要改。它们应该用于 # 你完成的功能。 # ================================================= ========================
def star():
""" Display a star without the normal new line """
print('*', end='')
def fill():
""" Display a fill character without the normal new line """
print('#', end='')
def space():
""" Display a space without the normal new line """
print(' ', end='')
def newline():
""" Display a new line """
print()
def displayTriangle(n):
for row in range(1, n + 1):
for col in range(row):
star()
newline()
newline()
def hockeyStick(handleLen, bladeLen):
""" Display a hockey stick where the handle is of length handleLen
and the blade is of length bladeLen.
- This example has handleLen = 6, bladeLen = 7
*
*
*
*
*
*
*******
"""
print('Hockey stick of size', handleLen, 'and', bladeLen)
曲棍球棒图案输出应该能够格式化为 "handleLen" 和 "bladeLen" 中的任何格式。我一直在尝试使用由 space 组成的三角形并在末尾添加一个星号,但我无法使用 "handleLen" 和 "bladeLen"。任何帮助表示赞赏。
def hockeyStick(handleLen, bladeLen):
""" Display a hockey stick where the handle is of length handleLen
and the blade is of length bladeLen.
- This example has handleLen = 6, bladeLen = 7
*
*
*
*
*
*
*******
"""
print('Hockey stick of size', handleLen, 'and', bladeLen)
for row in range(1, handleLen + 1):
for col in range(row-1):
space()
star()
newline()
for col in range(handleLen):
space()
for col in range(bladeLen):
star()