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
Technician A says that the ECT and IAT sensors can be tested by using a digital multimeter or a scan tool. Technician B says tha
lara31 [8.8K]

Answer:

A) Both Techician A and B are correct

Explanation:

IAT refers to the Intake Air Temperature sensor while ECT refers to Electronically Controlled Transmission sensor. The IAT is a thermistor whose values changes based on the air temperature entering the engine, the ECT controls engine revolution. The statements in the questions by both technicians are correct

3 0
3 years ago
Wight an essay on Knowledge sharing among robots.<br> please and please do not delete my question.
PolarNik [594]

Answer:

Writing an essay to robots is very bad. The robots could steal your information and essay. Never share essays with robots.

Explanation:

5 0
2 years ago
Concentric circles on a disk platter where data is stored;________
bagirrra123 [75]

Answer:

Tracks

Resilient File System (ReFS)

Explanation:

  1. Concentric circles on a disk platter where data is stored is called Tracks
  2. The new file system developed for Windows Server 2012 is called Resilient File System (ReFS). It allows increased stability for disk storage and improved features for data recovery and error checking
4 0
3 years ago
Are storage devices input devices
Nonamiya [84]

Answer:

Exphfbdplanation:

8 0
3 years ago
Manipulate the SQL statement to pull ALL fields and rows from Customers table that have a PostalCode of 44000. TIP: Since Postal
padilas [110]

Answer:

There are two customers in the PostalCode.

SQL statement for select all the fields and the rows from the Customers table where PostalCode is 44000.

SELECT *  FROM Customers  WHERE PostalCode = "44000";

Explanation:

The SELECT statement retrieve zero or more than one row from 1 or more than one the database tables or the database views.  

In most of the applications, the SELECT query is most commonly used for DQL(Data Query Language) command.  

SQL is the declarative programming language and the SELECT statement specifies the result set, but they do not specifies how to calculate it.

6 0
3 years ago
Other questions:
  • What is a main cause of a virus on a computer
    6·1 answer
  • If two cars got to a four way stop intersection at the same time which car should be yield the right-of- way
    12·1 answer
  • Which is the last step in conducting a URL search?
    5·2 answers
  • What is the difference between a key escrow and a recovery agent? (Choose all that apply.)
    12·1 answer
  • Which of the following operating systems is able to join a domain a) Microsoft office pro b) Microsoft surface R.T. c) google an
    9·2 answers
  • Examine the following declarations and definitions for the array-based implementations for the Stack and Queue ADTs. Assume that
    14·1 answer
  • Using hard disk to temporarily store data or instructions from ram is referred to as the
    12·1 answer
  • Tcp takes a three-step approach to establishing a reliable communication. first, from the transport layer of the sending device
    12·1 answer
  • Can somebody help me out
    15·1 answer
  • Write a program that accepts any number of scores ranging from 0 to 10
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!