Question

Python: Write a function that takes in a number as a parameter and calculates the square...

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.

Homework Answers

Answer #1

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

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
PYTHON: Write a function that takes in a number as a parameter and calculates the square...
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. The function must perform the process recursively.
Python: Write a recursive function that takes in a number as a parameter and calculates the...
Python: Write a recursive 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.
Write a Python function that takes a list of integers as a parameter and returns the...
Write a Python function that takes a list of integers as a parameter and returns the sum of the elements in the list. Thank you.
Write a Python function that takes a list of integers as a parameter and returns the...
Write a Python function that takes a list of integers as a parameter and returns the sum of the elements in the list. Thank you.
Write a Python function that takes a list of integers as a parameter and returns the...
Write a Python function that takes a list of integers as a parameter and returns the sum of the elements in the list. Thank you.
Write a Python program using that takes a number as input and then prints if the...
Write a Python program using that takes a number as input and then prints if the number is even or odd. The program should use a function isEven that takes a number as a parameter and returns a logical value true if the number is even, false otherwise.
Write a Python function that takes a filename as a parameter and returns the string 'rows'...
Write a Python function that takes a filename as a parameter and returns the string 'rows' if a file was written row by row, and 'columns' if the file was written column by column. You would call the function with a command like filetype = myfunc(filename).
In python (use loop, if, else...) a)Enter a function that calculates the maximum common divider of...
In python (use loop, if, else...) a)Enter a function that calculates the maximum common divider of 2 numbers. b)Write a function that asks for time in seconds and converts it into hours, minutes, and seconds
Python Jupyter Notebook Write a python function called profit that takes the number of meals (n)...
Python Jupyter Notebook Write a python function called profit that takes the number of meals (n) sold by a restaurant in a month and calculates the monthly profit given the following information: The selling price of each meal is 12 USD (same for all meals) There is a fixed cost of 2500 USD per month regardless of the number of meals sold. There is a variable cost of 6 USD per each meal sold profit= total revenue- total cost =...
Write a Python function evaluateFunction() that takes one floating point number x as its argument and...
Write a Python function evaluateFunction() that takes one floating point number x as its argument and returns 3√(log⁡|x| )+3(x^3) The math module has a square root function and a logarithm function