write a program to display Square of numbers from N to M in python?
Python program that prompts the user to input two integer values, N and M, representing the start and end points of the range of numbers we want to display the squares of.
Next, the program uses a for loop to iterate over each number in the range from N to M (inclusive). For each number, the program computes its square using the ** operator and displays it to the console using the print() function.
Python program that prompts the user to input two integer values, N and M, representing the start and end points of the range of numbers we want to display the squares of. Then, it uses a for loop to iterate over each number in the range from N to M (inclusive), computes its square using the ** operator, and displays it to the console using the print() function.
N = int(input("Enter the value of N: ")) M = int(input("Enter the value of M: ")) for i in range(N, M+1): print(i**2)
In this program, we first prompt the user to enter the values of N and M using the input() function and convert them to integers using the int() function.
We then use a for loop to iterate over all numbers from N to M (inclusive). For each number, we compute its square using the ** operator and display it to the console using the print() function.
The program thus outputs the squares of all the numbers in the range from N to M.