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
What term is the ability to restore service quickly and without lost data if a disaster makes your components unavailable or it
oksian1 [2.3K]

Answer:

"Recoverability" is the appropriate solution.

Explanation:

  • The above refers to either the DBMS work timetables where only certain processes are conducted out only when all transactions where such modifications are learned by the submission are implemented or operated.
  • This technique is used to reinstate make informed even without system failures.
8 0
3 years ago
Can an engine run on air? I think it can, but I am not sure
Svetlanka [38]

Hello,

NO, and engine can run on steam, gas and other things but not air.

-Bella

3 0
3 years ago
Read 2 more answers
4. Assuming that social networking at the resorts will require wireless communication and connection to the Internet, what are s
Studentka2010 [4]

Answer:

Social networking capabilities could be made available by the presence of SBRUs central servers and local resort's server. For resorts that are using SBRU servers, there will be high bandwidth access to the internet. This can create a service level of 100% availability. However, for the resorts with high usage clients, a local server could be provided. Similar support will be needed and it will encourage local communication. The possible issues will be problems of connectivity, reliability as well as bandwidth.

Explanation:

Social networking capabilities could be made available by the presence of SBRUs central servers and local resort's server. For resorts that are using SBRU servers, there will be high bandwidth access to the internet. This can create a service level of 100% availability. However, for the resorts with high usage clients, a local server could be provided. Similar support will be needed and it will encourage local communication. The possible issues will be problems of connectivity, reliability as well as bandwidth.

8 0
2 years ago
What is the maximum number of columns in a spreadsheet that you can sort in one instance in software like OpenOffice Calc?
MakcuM [25]
The correct answer is D
6 0
3 years ago
Read 2 more answers
Long-term memory used by the computer:
Fynjy0 [20]
The long term memory used by the computer is called “RAM”
6 0
2 years ago
Read 2 more answers
Other questions:
  • Which is the best method of marketing a game to casual players?
    14·2 answers
  • What type of traffic always goes to all devices in a subnet?
    10·1 answer
  • What should you do if your computer keeps shutting down while working?
    9·2 answers
  • Which result is most likely if a network packet has no header?
    9·2 answers
  • Write the algorithm and draw a flowchart to display the greatest number among any two different numbers....
    5·1 answer
  • _____the measuring instrument is not necssery​
    10·1 answer
  • OBJECTIVE QUESTIONS
    10·1 answer
  • Which of the following is not a use of a hash function
    7·1 answer
  • Explain why regular system cleanup is vital to ensuring the operating system runs efficiently. ?
    15·1 answer
  • What does a companys code of ehtics cover
    13·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!