Question: 1. Create a file named numbers.py and write a program to prompt user to input a number, then loops through the digits of the number

 1. Create a file named numbers.py and write a program to

1. Create a file named numbers.py and write a program to prompt user to input a number, then loops through the digits of the number to calculate sum of digits, prints the sum of the digits. Hint: You cannot iterate through digits of a number unless you first change it to a string. You cannot sum strings unless you change them to integer. Test your program with following examples: - Input: 137 Output: 11 Input: 1458 Output: 18 Enter a number to Sum digits: 137 The sum of digits in 137 is ll. Enter a number to Sum digits:1458 The sum of digits in 1458 is 18. 2. Create a file named triangle.py write code to output numbers as below. Make code dynamic so that if I input 7, the following will be output. 22 333 4444 55555 666666 If I input 10, the triangle will have up to 9 as below: 333 4444 55555 666666 7777777 88888888 999999999

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!