1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
abruzzese [7]
3 years ago
12

a. displays the sum of all even numbers between 2 and 100 (inclusive). b. displays the sum of all squares between 1 and 100 (inc

lusive). c. displays the powers of 2 from 1 up to 256. d. displays the sum of all odd numbers between a and b (inclusive), where a and b are inputs. e. displays the sum of all odd digits of an input. (For example, if the input is 32677, the sum would be 3 + 7 + 7 = 17.) You must achieve each step using a loop.
Computers and Technology
1 answer:
LuckyWell [14K]3 years ago
4 0

Answer:

The program required is in the explanation segment.

Explanation:

Program :

import math

# a. displays the sum of all even numbers between 2 and 100 (inclusive).

print("All even numbers from 2 to 100 inclusive ")

sum=0

i=2

while i<=100:

if i %2 ==0:

sum=sum+i

print(i,end=" ")

i=i+1

print("\nThe sum of all even numbers between 2 and 100 (inclusive) :",sum);

#b. displays the sum of all squares between 1 and 100 (inclusive).

print("\nAll squares numbers from 1 to 100 inclusive:")

i=1

sum=0

while i<=100:

print(i*i,end=" ")

i=i+1

sum=sum+(i*i)

print("\n\nThe sum of all squares between 1 and 100 (inclusive) is :",sum)

#c. displays the powers of 2 from 1 up to 256.

print("\nAll powers of 2 from 2 ** 0 to 2 ** 8:")

i=0

while True:

p=math.pow(2,i)

if p>256:

break

print("2 ** ",i," is ",int(p))

i=i+1

#d. displays the sum of all odd numbers between a and b (inclusive), where a and b are inputs

print("\nCompute the sum of all odd integers between two intgers ")

a=int(input("Enter an integer:"))

b=int(input("Enter another integer: "))

count = 0

temp=a

sum=0

while a<=b:

if a%2!=0:

print(a,end=" ")

sum=sum+a

a=a+1

print("\nThe total of the odd numbers from ", temp ," to ", b ,"is",sum)

#e.displays the sum of all odd digits of an input. (For example, if the input is 32677, the sum would be 3 + 7 + 7 = 17.)

print("\nCompute the sum of the odd digits in an integer ")

n=int(input("Enter an integer:"))

count=0

sum=0

temp=n

while n!=0:

rem = n%10

if rem%2!=0:

sum=sum+rem

count=count+1

n=int(n/10)

print("Sum of the odd digits is ",sum)

print("The total of the odd digits in ",temp," is ",count)

You might be interested in
A person is trying to remember a list of 12 different items:
erastova [34]

Answer:

for me personally, it would help if the items were rearranged with like items, for example: snow, sleet, rain, and hail would go together.

so the list should look something like this:

    <u>weather conditions</u>

  • snow
  • sleet
  • hail
  • rain

    <u>fruits</u>

  • strawberry
  • banana
  • apple
  • orange

   <u>sports</u>

  • football
  • soccer
  • tennis
  • rugby

hope i helped <3 have a nice day

5 0
3 years ago
Read 2 more answers
¿que significa “TTAQMMQMPDATLSPLNDTMGCCLFEQMMPQTEIUMDR” ?
OlgaM077 [116]

Answer: what

Explanation:

5 0
2 years ago
Read 2 more answers
What is an example of fibre optic cable<br>​
Arte-miy333 [17]

Answer:

printing cable

Explanation:

is a cable used to transfer information from a computer to the printer in packages

5 0
2 years ago
In which of the following situations would you want to use a word processing template?
creativ13 [48]
<h2>Answer:</h2>

<u>The correct answer is A. </u><u>You need to write a letter to a company you’d like to work with, and have specific questions to ask.</u>

<h2>Explanation:</h2>

Applying for a job is a very formal type of document which contains all the required and necessary information about a person who wants to apply. So a letter is typed in Microsoft word format to keep the document aligned and beautiful. Word template can make it professional which otherwise becomes hard to apply for a job in the absence of quality editing.

5 0
3 years ago
Read 2 more answers
Ed says that no matter how carefully he checks his CSS code and HTML markup, and has validated his document at the W3C Markup Va
slega [8]

Answer:

Try another browser

Explanation:

Some browsers do not support advanced features like flex box.

5 0
2 years ago
Other questions:
  • You can access decorative underlines and change their color through the ____ drop-down.
    8·1 answer
  • Discuss some design considerations that you should keep in mind when you want to design a professional-looking flyer or newslett
    5·2 answers
  • Hello my friends i am trying to reboot my i phone 4 but i could not i tried many ways can u help me
    14·1 answer
  • Define a method printFeetInchShort, with int parameters numFeet and numInches, that prints using ' and " shorthand. End with a n
    7·2 answers
  • _____ interviews rely on scenarios and reflections to evaluate an applicant’s skill set.
    9·2 answers
  • My feelings alwayss T-T
    14·2 answers
  • In a three-tier architecture, the component that runs the program code and enforces the business processes is the:_______.
    11·1 answer
  • 10. Differentiate between equity share &amp; preference share.​
    11·1 answer
  • Lucas wants to expand his vocabulary to better understand the sentence below. The insidious burglar moved through the house unhe
    7·2 answers
  • Pls help I will give points
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!