python 2nd 条件控制之while语句
2021/8/28 14:07:01
本文主要是介绍python 2nd 条件控制之while语句,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
实例
while True: s = input('Enter something : ') if s == 'quit': break print('Length of the string is', len(s)) print('Done')
实例
while True: s = input('Enter something : ') if s == 'quit': break else: print('Length of the string is', len(s)) print('Done')
实例 猜数字 while语句
number = 23 running = True while running: guess = int(input('Enter an integer : ')) if guess == number: print('Congratulations, you guessed it.') # 这将导致 while 循环中止 running = False elif guess < number: print('No, it is a little higher than that.') else: print('No, it is a little lower than that.') else: print('The while loop is over.') # 在这里你可以做你想做的任何事 print('Done')
这篇关于python 2nd 条件控制之while语句的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-11-16`PyMuPDF4LLM`:提取PDF数据的神器
- 2024-11-16四种数据科学Web界面框架快速对比:Rio、Reflex、Streamlit和Plotly Dash
- 2024-11-14获取参数学习:Python编程入门教程
- 2024-11-14Python编程基础入门
- 2024-11-14Python编程入门指南
- 2024-11-13Python基础教程
- 2024-11-12Python编程基础指南
- 2024-11-12Python基础编程教程
- 2024-11-08Python编程基础与实践示例
- 2024-11-07Python编程基础指南