Ask
your own question, for FREE!
MIT 6.00 Intro Computer Science (OCW)
31 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
addison123456:
I have a quote that will hit hard but someone needs to tell me what it means. "I am not crying over you.
breiadabrattzz:
Do anyone know how to use Canva and do like personal photos for UNT Denton and in
xXAikoXx:
Can peanut oil cause allergic reactions to someone with a peanut allergy?
gelphielvr:
How does a person's community (where they are from, who they surround themselves with, their u201cpeopleu201d, etc.
Nina001:
I need ideas on what religion I should do on my history project and some good facts.
gelphielvr:
Based on the 1920s identify new behaviors, dress, and attitudes of women in Ameri
gelphielvr:
How did buying on credit create an economic boom in the 1920s?
gelphielvr:
Where are the different types of valance electrons located on the periodic table?
33 minutes ago
13 Replies
0 Medals
39 minutes ago
31 Replies
3 Medals
20 seconds ago
12 Replies
0 Medals
6 hours ago
2 Replies
1 Medal
11 hours ago
4 Replies
0 Medals
22 hours ago
12 Replies
1 Medal
9 hours ago
6 Replies
1 Medal
2 days ago
3 Replies
3 Medals