What do i do to create this loop?


#1

I was given a question on paper to create a loop but i don’t understand what im supposed to do.
Question:
Define a function called quartered that takes x as a parameter.
In the function, write a for loop that iterates through the length of x, dividing each element by 4.
Create a list called test_nums comprised of 4, 12, 28, 36, 80.
Write a print statement calling the function on test_nums. What would you expect the output to be?

I defined a function already but i don’t understand what they mean by write a for loop that iterates through the length of x, dividing each element by 4. What am i supposed to write?


#2

you could use a for loop to loop over the elements in the list? Then print the element divided by 4?


#3

And how do i divide it?


#4

python has a division operator (/), you should be able to use that


#5

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.