Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PLEASE IN PYTHON ONLY........ This assignment will give you more experience on the use of loops In this project, we are going to compute the

PLEASE IN PYTHON ONLY........

This assignment will give you more experience on the use of loops

In this project, we are going to compute the number of times a given digit D appears in a given number N. For example, the number of times 5 appears in 1550 is 2. The number of times 0 appears in 1550 is 1. The number of times 3 appears in 155 is 0. Etc.

Task

Your task is to implement the following the algorithm.

1- initialize a counter to 0

2- decompose the number N into its corresponding digits by calculating quotients and remainders of dividing it by 10

3- increment the counter each time the digit D appears

Example:

Given the number N = 1550 and the digit D = 5:

Calculated Digit

Counter

0

0

5

1

5

2

1

2

Given the number N = 96395 and the digit D = 9:

Calculated Digit

Counter

5

0

9

1

3

1

6

1

9

2

Project Description / Specification

1. Prompt the user for the given number and the given digit.

2. The program should have error checking to make sure the user inputs are valid. For example, if a user gives non-integer inputs, notify the user that the inputs are incorrect and prompt again.

3. Decompose the number in a loop and increment the counter within the loop as described in the example above.

Sample Interaction:

image text in transcribed

Python Shell Enter a number -> Number entered is 1550 Enter a digit -> 5 Digit entered is 5 The number of 5 's in 1550 is 2 RESTART Enter a number -> Number entered is 1550 Enter a digit ---> 0 Digit entered is 0 The number of 0 's in 1550 is 1 RESTART Enter a number -> Number entered is 1550 Enter a digit -> 3 Digit entered is 3 The number of 3's in 1550 is 0 Ln: 111/Col: 4|

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored 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

Recommended Textbook for

Modern Database Management

Authors: Donald A. Carpenter Fred R. McFadden

1st Edition

8178088045, 978-8178088044

More Books

Students also viewed these Databases questions