Ask
your own question, for FREE!
MIT 6.00 Intro Computer Science (OCW)
30 Online
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
xXAikoXx:
What needs to be done before choosing and reading a book? A. Make sure it is nonfiction.
gelphielvr:
(chemistry 2 questions) 1. Differentiate between the plum pudding model and the nuclear model for the atom.
gelphielvr:
(logistics) If the king does not castle and the Pawn advances then either the Bishop is blocked or the Rock is pinned.
Tylerr:
Does anyone know of any reputable websites offering scholarships, or where one ca
vannieduval:
Yall need to make a section for boredom and random thoughts
Jayisbetterfrfr:
Sometimes I beat up myself, I block my own way I cloud all my thoughts, please go
Luna34:
Mending Glass A heart once whole, now cracked and worn, Its edges sharp, its fabric torn, A silent cry, a whispered ache, From love once real, now past the
Luigi0210:
Bromine has 2 isotopes Br-79 and Br-81. The smaller isotope is 51% of the atoms on earth.
TheVoid:
Any other plurals or systems (DID/OSDD) on QC? (if you don't know what those are
20 minutes ago
2 Replies
1 Medal
2 hours ago
4 Replies
2 Medals
3 hours ago
17 Replies
2 Medals
4 hours ago
9 Replies
2 Medals
4 hours ago
9 Replies
0 Medals
15 minutes ago
5 Replies
2 Medals
6 hours ago
3 Replies
3 Medals
21 hours ago
9 Replies
4 Medals
2 hours ago
25 Replies
4 Medals