python随便写个代码
时间: 2023-02-08 10:52:09 浏览: 83
当然可以,你想要写什么样的代码呢?
```python
print("Hello, World!")
```
这是一个简单的 "Hello, World!" 程序。它会在运行时输出 "Hello, World!"。
相关问题
随便写一个Python游戏代码
好的,以下是一个简单的石头剪子布游戏的Python代码:
```
import random
print("欢迎来玩石头剪子布游戏!")
print("输入 1 代表石头,2 代表剪子,3 代表布")
while True:
user_choice = int(input("请出拳:"))
while user_choice not in [1, 2, 3]:
user_choice = int(input("请出拳(1, 2 或 3):"))
computer_choice = random.randint(1, 3)
print("电脑出拳:", computer_choice)
if user_choice == computer_choice:
print("平局!")
elif user_choice == 1 and computer_choice == 2 \
or user_choice == 2 and computer_choice == 3 \
or user_choice == 3 and computer_choice == 1:
print("恭喜您!您赢了!")
else:
print("很遗憾,您输了。")
play_again = input("再来一局?(输入 y 或 n):")
if play_again.lower() != "y":
break
print("游戏结束。")
```
希望您喜欢这个游戏!
随便写个代码
好的,以下是一个简单的Hello World程序,使用Python语言编写:
```python
print("Hello World!")
```
当你运行这个程序时,它会输出“Hello World!”这个字符串。