【Python】题集 of ②
2023-02-18 15:50:05 时间
?write in front? ?个人主页:打打酱油desu_泽En_CSDN博客? ?本文由 泽En 原创 CSDN首发? 如需转载还请通知⚠ ?2021年度博客之星物联网与嵌入式开发TOP5→作者周榜56→总排名2919? ?欢迎各位→点赞? + 收藏⭐️ + 留言? ?系列专栏:【Python】题目_打打酱油desu-CSDN博客? ?总结:希望你看完之后,能对你有所帮助,不足请指正!共同学习交流 ? ✉️我们并非登上我们所选择的舞台,演出并非我们所选择的剧本?
- 第六题:描述:打印9*9的乘法口诀表(用for循环)
- 第七题:描述:随机打印直角三角形
- 第八题:描述:等腰三角形打印
- 第九题:描述:猜拳系统小游戏
- 第十题:描述:统计1到100之和(用for循环)
目录
⭐第六题:代码
for i in range(1, 10):
for j in range(1, i+1):
print(f'{j}x{i}={i*j} ', end='')
print()
⭐第七题:代码
number = int(input('请输入数字...'))
row = 1
while row <= number:
col = 1
while col <= row:
print('◻',end=' ')
col += 1 # col = col + 1
pass
print() # 换行
row += 1
⭐第八题:代码
row = 1
while row <= 10:
j = 1
while j <= 10-row:
print(' ',end=' ') # 前面9行为空格
j += 1 # 根据j的表达式的值为真还是为假
pass
# 控制打印符号
k = 1
while k <= 2*row-1:
print('◻',end='')
k += 1 # 执行打印符号k就+1,注意如果这里是打印三个◻,它并不是直接打印◻,而是每次打印都要回到while循环,这样就是每次打印◻,就是加一次k
pass
print() # 换行
row += 1 # 执行完之后row+1
⭐第九题:代码
import random # 生成随机值
person = int(input('请输入猜拳[0石头,1剪刀,2布]:...'))
computer = random.randint(0,2) # rand();功能随机生成数字 0~32767之间
# 打印三种情况
# 人 赢了
if person == 0 and computer == 1:
print('老铁666')
pass
elif person == 1 and computer == 2:
print('老铁666')
pass
elif person == 2 and computer == 0:
pass
print('老铁666')
pass
# 平手
elif person == computer:
print('下次一定')
pass
# 输了
else:
print('不服再来')
⭐第十题:代码
tmp = 0
for i in range(1,101):
tmp = tmp + i
print("sum = %d" % tmp)
相关文章
- 从零到熟悉,带你掌握Python len() 函数的使用
- [Python] for in单行循环生成dict
- [Python]reduce() 函数
- [Python]Python日期格式和字符串格式相互转换
- [Python]Python中使用正则表达式匹配
- [Python]Python 列表(List)
- [Python]python中assert和isinstance的用法
- [python]Python 中 if not 用法
- [python]Python 字典(Dictionary) update()方法
- Python 爬虫进阶必备 | 某恩数据网排行加密数据解密逻辑分析
- [python]python中的一些包以及他们的基本用处和安装
- [python]ubuntu下的python2和python3
- [Python] 关于__init__.py
- [Python]安装和运行flask框架
- Python 的 sum():Pythonic 的求和方法
- 送你一个Python 数据排序的好方法
- 5种Python使用定时调度任务的方式
- 教你用Python 编写 Hadoop MapReduce 程序
- [Python] for in单行循环生成dict
- [Python]reduce() 函数