Consider the following line of code:
print( 6**2 == 72/2 )
What will the output be?
Consider the following line of code:
(10**2 - 10) % 9
What will the output be?
Consider the following line of code:
(1, 2, 3, 4, 5, 6)[4]
What will the output be?
Consider the following line of code:
(1, 2, 3, 4, 5, 6)[1:5:2]
What will the output be?
Consider the following block of code:
container = []
for i in range(6):
container.append(6 - i)
print(container)
What type of object is container?
Write out the output of print(container).
Give an example of a string.
What is the difference between a float and an integer?
I want to define a function that takes a number as an input and outputs the sum of squared numbers less than the input number. For example, if I input the value 5, I want the function to output 30 (since 30 = 12+22+32+42). What I made was the following block of code.
def squares(maximum):
container = []
for i in range( maximum ):
container.append(i)
container2 = []
for j in container:
container2.append( j**2 )
container3 = 0
for k in container2:
container3 += k
return container3
In words, describe how to make this function shorter (that is, less lines of code).