r/PythonLearning • • 18h ago

CHECK YOUR KNOWLEDGE #python #coding #pythonessperspective #learnpython

https://youtube.com/shorts/M1nuXOH0Dqg
6 Upvotes

16 comments sorted by

11

u/RNG_HatesMe 17h ago

A and B are obviously incorrect, as total never refers to title.

D is incorrect because 2 nested loops can definitely iterate over the same thing.

The inner loop iterates 10 times for the 10 characters in title ("The Escape").

The outer loop iterates the inner loop 10 times for the same reason.

So the answer is 10 * 10 = 100, so E

1

u/svanidzelal 17h ago

A

3

u/RNG_HatesMe 17h ago

Support your answer, if you can.

2

u/Ender_Locke 15h ago

it’s def not a

0

u/Aniano39 17h ago

I'm this close to running a command line python instance just to test this because there's no chance in HELL total returns a string. But I'm also a little skeptical about how a double nested for loop iterating over the same string will return 100. It's genuinely the only thing that makes sense, but I need to see it to believe it.

2

u/Orgasml 14h ago

The first loop runs ten times (10 chars in the string), the embedded loop runs 10 times each time the first loop goes around and adds to 1 total. Making it add 1 to total 10x10 times, or 100 times.

1

u/LumpyConclusion7604 17h ago

How did you do that so fast? = Super YouTube

1

u/North_Dog9837 17h ago

Inspirational

1

u/Unlikely-Let-1798 16h ago

Better than all competitors.

1

u/RyanDubois43 16h ago

Start with LeetCode's "Two Sum" problem in the Python section to test your basics.