Project Description
Your task for today is to write a Python program that repeatedly asks the user to enter a number and prints its square. The program should keep running until the user types "q"
to quit.
This kind of loop is commonly used in real-world apps that continuously take user input, such as calculators or command-line tools.
Expected Output
The program should work like this:
As you can see, the program asks the user to enter a number. The user enters “4” and the program prints out the message “Square: 16”. The user can continue to enter numbers, but if they enter “q” the program should quit.
💡 Hint
Don’t know where to start? This hint will show you how to begin.
𝌣 Solution
🔒 This solution is available to paid subscribers only.
🚀 Want to keep leveling up?
Browse 200+ projects at dailypythonprojects.substack.com/archive and unlock all solutions by subscribing. Build real Python skills daily and transform how you learn — one project at a time.
While True:
R = input("Number to square or q to quit. > ").lower()
break if R == "q" else print( int(R)**2 )