Q:

Write a Python function to create and print a list where the values are square of numbers between 1 and 20

0

Write a Python function to create and print a list where the values are square of numbers between 1 and 20

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

I have used python 3.7 compiler for debugging purpose.

def printValues():
    l = list()
    for i in range(1,21):
        l.append(i**2)
    print(l)
 
printValues()

Result:

[1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289, 324, 361, 400]

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Write a Python program to access a function inside... >>
<< Write a Python function that prints out the first ...