In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
This article editor for you detailed introduction of "python how to guess numbers 1 to 10", the content is detailed, the steps are clear, the details are handled properly, I hope this "python how to guess numbers 1 to 10" article can help you solve doubts, following the editor's ideas slowly in depth, together to learn new knowledge.
Method description
1. The input number can be realized by the input () function, the comparison number can be realized by the conditional judgment sentence if, and the output result can be realized by the print () function.
2. If you need to make multiple comparisons, you need to use a for loop or a while loop.
Example
Import randomsecretnum = random.randint (1mai 10) count = 3print ("guessing number game, with numbers between 1 and 10) You have {0} chances. Format (count) while (count > 0): num = input ("enter a number:") if num.isdigit (): num = int (num) if num = = secretnum: print ("right") break elif num < secretnum: print ("smaller") else: print ("big") count-= 1 if count = = 0: print ("you don't have a chance") break print ("you still have {0} chances left" .format (count)) else: print ("you entered not a number Please re-enter ") print (" Game over ") to read here, this" how to guess numbers 1 to 10 "article has been introduced, want to master the knowledge of this article also need everyone to practice and use in order to understand, if you want to know more related articles, welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.