[Tutor] (no subject)

dn PyTutor at danceswithmice.info
Sun Jul 26 20:14:44 EDT 2020


On 27/07/2020 10:15, sophia lore wrote:
> Create a program that iterates using a *for loop* over all values of
> list_mod. The program must check each value and append the string "True" to
> the list result if the value is even or append the string "False" to the
> list result otherwise.
> 
> ### GRADED
> 
> list_mod = list(range(1,15))
> result = []
> 
> I have been working on this question for class for two days. I have tried
> numerous combinations of if/else statements in the for loop to achieve the
> outcome requested. All of the code I have tried returns errors. I can't
> seem to grasp how to set this up. Any help would be appreciated.


Sorry to hear that the problem is frustrating you. What numerous 
combinations have you tried? (please copy-paste the code, and any 
error-messages into your reply email msg)

We are prepared to help you learn - but not to do your homework/win the 
grade for you!


What should be the for-loop that will iterate over list_mod?
How can one decide if a value is odd or even? (what  is the definition 
of "even")
Computing "4 / 2" or "4 * 0.5" is easy,  isn't it?
What about "5 / 2" (or...)?
What if those two results are expressed as floating-point numbers, and 
then again but as integers?

If you can answer those questions, the solution will become more clear...
-- 
Regards =dn


More information about the Tutor mailing list