Ask
your own question, for FREE!
MIT 6.00 Intro Computer Science (OCW)
I don't get the program at the end of lecture 3. http://dpaste.com/603441/ why is the result 17?
Still Need Help?
Join the QuestionCove community and study together with friends!
The function is summing the digits of the string, so 1+9+5+2 = 17
sumDigits = 0 for c in str(1952): sumDigits += int(c) print sumDigits yeah, the for loop takes each digit, starting with the first and adds it to the previous, then prints the final result after the loop ends. sumDigits equals 1 on the first go around, then it equals 1 + 9 (10), then 10 + 5, etc.
Can't find your answer?
Make a FREE account and ask your own questions, OR help others and earn volunteer hours!
Join our real-time social learning platform and learn together with your friends!
Join our real-time social learning platform and learn together with your friends!
Latest Questions
InsatiableSuffering:
Looking for some constructive criticism for my soon-to-be character model. Before I attempt rigging the character, I would like to know what I can do to imp
Olive2006:
Sara tried to compute the mean of her 8 test scores. She mistakenly divided the correct sum of all her test scores by 7, which yields 96.
Axolotl:
The figure shows a construction completed by hand. (The photo is the comments) Does the construction demonstrate how to copy a segment correctly by hand? Ju
lildizzy:
Language changes with time and context. What is your opinion about what constitutes good or bad usage? Is it necessary for speakers or writers to follow a p
Gucchi:
Which of the following describes ecosystem services? I. Erosion II. Timber III. W
dgreer4:
Which of the following involved a protest over taxation in front of the governors building in Massachusetts in 1770? A).
Gucchi:
Read the story description and historical context for the short story "Daughter of Invention" and answer the question.
MusicGeek:
https://voca.ro/17zoRsUUmmfh Diddy - Dirty Money - Coming Home ft. Skylar Grey is
2 hours ago
19 Replies
2 Medals
4 hours ago
1 Reply
1 Medal
5 hours ago
1 Reply
0 Medals
7 hours ago
0 Replies
0 Medals
7 hours ago
1 Reply
0 Medals
8 hours ago
3 Replies
2 Medals
10 hours ago
0 Replies
0 Medals
9 hours ago
2 Replies
0 Medals