Python to calculate the sum of the numbers from 1 to 1000, inclusive, except omitting from the summation any number that has a 1 as one of its digits. For example, the sum of numbers from 1 to 10, inclusive without numbers that contain a 1 is: 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 = 44, since we are excluding the numbers 1 and 10 which contain a 1. In this example you would answer with the single integer value 44.  Note that the condition str(1) in str(10) is True, whereas str(1) in str(8) is False

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter5: Control Structures Ii (repetition)
Section: Chapter Questions
Problem 14PE
icon
Related questions
Question

 

 

Use Python to calculate the sum of the numbers from 1 to 1000, inclusive, except omitting from the summation any number that has a 1 as one of its digits. For example, the sum of numbers from 1 to 10, inclusive without numbers that contain a 1 is: 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 = 44, since we are excluding the numbers 1 and 10 which contain a 1. In this example you would answer with the single integer value 44.  Note that the condition str(1) in str(10) is True, whereas str(1) in str(8) is False.

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning