January 15, 2020 at 12:00 am
Comments posted to this topic are about the item Python Map
January 15, 2020 at 5:19 am
Nice question, thanks Steve
____________________________________________
Space, the final frontier? not any more...
All limits henceforth are self-imposed.
“libera tute vulgaris ex”
January 15, 2020 at 8:48 am
the second line of code inside your function should be indented
def calcsq(n):
return n*n
January 15, 2020 at 1:19 pm
A little bit tricky for me, the code as is (ignoring the missing indentation) would fail since calcsq is defined as calcsq then called as calcSq, the differing case would result in an exception. Fortunately returning an exception wasn't one of the available choices or I wouldn't have dug any further. Additionally print(result) doesn't print the values from the map object it prints "<map object at 0x000001..." you need to convert it to a set or list first to see the values in a print command (Python 3.7), good thing all the answers were lists or I wouldn't have dug deeper here either. Good question, I'm new to python so these questions give me direction of what functions to go learn about and play with. I find these very valuable, thanks.
-
January 15, 2020 at 1:26 pm
Will not execute with indent error.
January 15, 2020 at 1:28 pm
Jason, Hahahaha, love it! Keep up the good work.
January 15, 2020 at 1:30 pm
Hahahaha, love it! Keep up the good work.
January 15, 2020 at 3:05 pm
I've added the indentation and corrected the case of calcsq.
Thanks,
Kathi
January 15, 2020 at 4:32 pm
The print statement also needs to be changed to print(list(result))
January 15, 2020 at 5:08 pm
Picky, picky, picky. If you expect perfection in the questions, sorry, but that may not happen. Personally, I am lucky to even be able to spell Python as I don't currently use it. So I thought about the question logically, figured that calcsq computed the square of a value and that the map some how iterated over the list. Made the correct choice.
Hoping this means when I start work on learning Python it shouldn't be too difficult since I seem to be able to grasp some of the concepts.
January 15, 2020 at 6:33 pm
OK, corrected that, too.
January 15, 2020 at 6:37 pm
Hmmm ... oddly, print (result) in Python v2.7.13 displays the result correctly. No need to add list().
January 15, 2020 at 6:47 pm
Well that's strange. I'm just starting to learn Python and have v3.8.1 installed. If I use print(result) I get <map object at 0x00000000027C6E80>. If I use print(list(result)) I get [4, 9, 16, 25].
January 16, 2020 at 12:24 pm
Lynn Pettis, the difference in genetic structure between humans and chimps is around 4%. The pickyness of evolution is what gave rise to humans. One error in one line of code could result in AI eradicating biological life. We need to teach our developing programmers that pickyness is everything. 😉
January 16, 2020 at 12:27 pm
Now I wait for someone to be picky and correct my spelling of pickiness.
Viewing 15 posts - 1 through 15 (of 16 total)
You must be logged in to reply to this topic. Login to reply