当前位置:网站首页>Example 046: Breaking the Cycle

Example 046: Breaking the Cycle

2022-08-10 03:32:00 lazily

Title:Squaring the input number, if the square is less than 50, exit.

Program Analysis:None

Instance 046: Breaking the loop break and continue usage

I. Code

while True:try:n = float(input('Enter a number: '))except:print('input error')continuedn = n**2print('The square is:', dn)if dn < 50:print('The square is less than 50, exit')break

Second, running results

↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓LazyXiaofan sincerely invites you to click below to learn and discuss together↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓

原网站

版权声明
本文为[lazily]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/222/202208100201343400.html