| |
|
|
开发:
C++知识库
Java知识库
JavaScript
Python
PHP知识库
人工智能
区块链
大数据
移动开发
嵌入式
开发工具
数据结构与算法
开发测试
游戏开发
网络协议
系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程 数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁 |
| -> Python知识库 -> python学习第一天 -> 正文阅读 |
|
|
[Python知识库]python学习第一天 |
|
python学习第一天 1、小游戏 import random
while True:
user = int(input("用户请出拳(0:退出游戏,1:石头,2:剪刀,3:布)"))
if user == 1 or user == 2 or user == 3:
pass
elif user == 0:
print("game over")
break
else:
print("请从新出拳必须是1,2或者3")
continue
computer = random.randint(1, 3)
print("user:", user, "computer:", computer)
if user == computer:
print("平局")
elif (user == 3 and computer == 1) or (user == 2 and computer == 3) or (user == 1 and computer == 2):
print("用户赢")
else:
print("电脑赢")
2、for循环 big="adasdad1"
for i in big:
print(i)
for index,i in enumerate(big):
if i=="a":
continue
print(index,1)
print(i,end=",")
3、while循环 #
# i = 0
# while i < 4:
# print(i + 1, "吃苹果")
# j = 1
# while j <= 4:
# print(j, "吃橘子")
# if j == 2:
# print("我吃饱了")
# break
# j += 1
# i += 1
#
#
# i = 1
# while i <= 4:
# if i == 3:
# i += 1
# continue
# print(f"吃{i}个苹果")
# i += 1
#
# print("===========")
# str="python"
# j = 0
# while j <6:
# if j == 1 or j ==4:
# print(str[j])
# j += 1
#
#
# for i in "aaaa":
# if i =="m":
# continue
# print(i,end=' ')
for i in range(1,6):
print("*" * i)
for i in range(1,6):
if i % 2 == 1:
print("*" * i)
|
|
|
|
|
| 上一篇文章 下一篇文章 查看所有文章 |
|
|
开发:
C++知识库
Java知识库
JavaScript
Python
PHP知识库
人工智能
区块链
大数据
移动开发
嵌入式
开发工具
数据结构与算法
开发测试
游戏开发
网络协议
系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程 数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁 |
| 360图书馆 购物 三丰科技 阅读网 日历 万年历 2025年12日历 | -2025/12/3 12:16:35- |
|
| 网站联系: qq:121756557 email:121756557@qq.com IT数码 |