# 等待输入字符串
message = input("Tell me something and I will repeat it back to you:")
print(message)
name = input("What's your name:")
print(f"Hello {name}!")
# 输入整数
age = input("How old are you?")
print(f"You are {int(age)} years old")
# while循环
current = 1
while current <= 5:
print(current)
current += 1
# break && contine
while True:
current += 1;
if current > 10:
break;
if current % 2 == 0:
continue;
print(current)
第七章 用户输入和while循环
最新推荐文章于 2024-07-22 15:15:29 发布
本文展示了Python中基本的交互式编程,包括获取用户输入、使用while循环和break/continue语句。通过实例解释了如何处理整数输入、控制循环流程以及简单的条件判断。
摘要由CSDN通过智能技术生成