1. Engineering
  2. Computer Science
  3. sum of digits in class weve seen a tor loop...

Question: sum of digits in class weve seen a tor loop...

Question details

Sum of digits In class weve seen a tor loop used to iterate over lines in a tile. A tor loop can actually be used to iterate over any sequence of values, so includes 1ist and sr types First, experiment a bit with the tor loop -what happens when you write a for loop that iterates over a at? rd - print(thing) what thing? Once youve worked this out, write a program that will rompt the user for a number. Using a tor loop, calculate the sum of digits. Your output should look something like (highlighted text means the user typed this in): The sum of the digits is 6
Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution