Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to realize number guessing Mini Program by Python

2025-03-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly introduces Python how to achieve number guessing Mini Program, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.

Guess the number Mini Game, constantly enter the number you guess (1-100), the program will remind you to adjust the size of the guess properly according to your input, until finally guess the random number''guessNumber = random.randint (1100) print ("I'm thinking a number between 1 and 100.") while True: print (' Take a guess.') Guess = int (input ()) if guess > guessNumber: print ("It's too high") elif guess < guessNumber: print ("It's to low") else: print ("Congratulations, you win.") Break

Result

Collatz sequence

Code

# Collatz sequence def collatz (number): if (number% 2 = = 0): return number / 2 else: return number * 3 + 1print ('Input a number.') while True: global number1 try: number1 = int (input () except ValueError: print (' Please input a number') continue if collatz (number1)! = 1: print (int (collatz (number1) Else: print (int (collatz (number1) break

Result

Thank you for reading this article carefully. I hope the article "how to achieve number guessing Mini Program with Python" shared by the editor will be helpful to everyone. At the same time, I also hope you will support us and follow the industry information channel. More related knowledge is waiting for you to learn!

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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report