Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

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

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions