添加九九乘法表程序
- 创建test.py实现九九乘法表 - 添加.gitignore忽略不必要的文件 - 包含任务要求文件
This commit is contained in:
22
.gitignore
vendored
Normal file
22
.gitignore
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
# Claude Code configuration
|
||||
.claude/
|
||||
|
||||
# Python bytecode
|
||||
__pycache__/
|
||||
*.py[cod]
|
||||
*$py.class
|
||||
|
||||
# IDE files
|
||||
.vscode/
|
||||
.idea/
|
||||
*.swp
|
||||
*.swo
|
||||
|
||||
# OS files
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
|
||||
# Virtual environments
|
||||
venv/
|
||||
env/
|
||||
.env
|
||||
44
test.py
Normal file
44
test.py
Normal file
@@ -0,0 +1,44 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
九九乘法表程序
|
||||
打印完整的9x9乘法表
|
||||
"""
|
||||
|
||||
def print_multiplication_table():
|
||||
"""打印九九乘法表"""
|
||||
print("九九乘法表:")
|
||||
print("=" * 50)
|
||||
|
||||
# 打印表头
|
||||
print(" ", end="")
|
||||
for i in range(1, 10):
|
||||
print(f"{i:4}", end="")
|
||||
print()
|
||||
print("-" * 50)
|
||||
|
||||
# 打印乘法表内容
|
||||
for i in range(1, 10):
|
||||
print(f"{i} |", end="")
|
||||
for j in range(1, 10):
|
||||
print(f"{i*j:4}", end="")
|
||||
print()
|
||||
|
||||
print("=" * 50)
|
||||
|
||||
def print_triangle_multiplication_table():
|
||||
"""打印三角形格式的九九乘法表"""
|
||||
print("\n三角形格式九九乘法表:")
|
||||
print("=" * 30)
|
||||
|
||||
for i in range(1, 10):
|
||||
for j in range(1, i + 1):
|
||||
print(f"{j}×{i}={i*j:2}", end=" ")
|
||||
print()
|
||||
|
||||
print("=" * 30)
|
||||
|
||||
if __name__ == "__main__":
|
||||
print_multiplication_table()
|
||||
print_triangle_multiplication_table()
|
||||
1
开发及提交要求.txt.txt
Normal file
1
开发及提交要求.txt.txt
Normal file
@@ -0,0 +1 @@
|
||||
请基于当前目录下完成一个九九乘法表的test.py程序,提交并推送远程仓库ssh://git@82.156.249.211:2222/htdw766/aicode.git
|
||||
Reference in New Issue
Block a user