Python: Write a function that takes in a number as a parameter and calculates the square of the number up to and including the value of the parameter. Please use a while or for loop.
Required function is given below:
def sqnum(a): #takes the number as parameter
for i in range(1,a+1):#iterates from 1 to given no.
print(i*i) #print the square of a number
Screenshots of above function output is shown below:
PLEASE UPVOTE THE ANSWER AND FEEL FREE TO ASK YOUR DOUBTS IN COMMENT SECTION
Get Answers For Free
Most questions answered within 1 hours.