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
tresset_1 [31]
3 years ago
10

Write a loop that reads positive integers from standard input and that terminates when it reads an integer that is not positive.

After the loop terminates, it prints out, on a single line and separated by a single space, the sum of all the even integers read and the sum of all the odd integers read. python
Computers and Technology
1 answer:
Paraphin [41]3 years ago
3 0

Answer:

The program to this question as follows:

Program:

#defining variable and assign value

odd=0  

even=0  

i=1  

print('Input 0 after inserting all number: ') #print message

while i>0: #define loop for check inserting and add all number

   i=int(input()) #input value by user end

   if (i< 0): #check value is not positive

       break

   if ((i % 2)==0and(i>0)): #check even number condition

       even=even+i #add even numbers

   if ((i % 2)!=0and(i>0)): #check odd number condition

       odd=odd+i #add odd numbers

print ('Sum of Even number:',even,'and','Sum of Odd number:',odd) #print value

Output:

Input 0 after inserting all number:  

1

2

3

5

7

0

Sum of Even number: 2 and Sum of Odd number: 16

 Explanation:

In the above python program, three variable is defined, that is "even, odd and i", in which "even and odd" variable assign value that is "0", and the variable i is used for inserting elements from user. In the next line a while loop is defined that inserts numbers in variable "i", in this loop, 3 if block is used that can be defined as follows:

  • In first if block variable "i", checks that value is non-positive number if this condition is true, it will break the loop.
  • In second if block this block check even number condition and add in even variable.
  • In third, if block this block check odd number condition and add in odd variable.  

End of the loop we use print function that prints the sum of even numbers and odd numbers.

You might be interested in
Who Find the exact web server that hosted the website by looking in a huge database of internet addresses
son4ous [18]

Answer:

The Internet service provider (ISP)

Explanation:

The internet service provider provides individuals and other companies access to the internet and other web services. The internet service provider looks through a huge database of internet addresses to find the exact web server that a website is hosted on when a query is sent.

4 0
3 years ago
software that instructs the computer how to run applications and controls the display/keyboard is known as the what?
Tomtit [17]
<span>The software that instructs the computer how to run applications and controls the display /keyboard is known as DRIVERS software, A driver is a software program that enables a specific hardware device to work with a computers operating system. Drivers may be required for internal components such as video cards and optical media drives.</span>
7 0
3 years ago
To clarify a word while reading, a
Crazy boy [7]

Answer:

look up the word in the dictionary and break it down

Explanation:

4 0
3 years ago
To activate Spelling and Grammar check using the ribbon, navigate first to the _____ tab
ipn [44]
I believe you would click on the Auto Correct Tab
7 0
3 years ago
Read 2 more answers
Suppose income is 4001, what is the output of the following code? if (income &gt; 3000) { System.out.println("Income is greater
grandymaker [24]

Answer:

Output:

Income is greater than 3000

Explanation:

In conditional statements, either the if statement is processed or the else if.

In this scenario, both the given conditions fit for the given output but when if block will be processed, the else if block will be skipped by default.

So the output will only be the out phrase of if block which is:

Income is greater than 3000.

8 0
3 years ago
Other questions:
  • An operating system cannot run from an external drive. true or false
    15·1 answer
  • How do computers read zeroes and ones?
    7·1 answer
  • 1. A microprocessor supports a single hardware timer. Suppose instruction SET_TIMER permits one to set the timer value1. Does th
    15·1 answer
  • The combined resistance of three resistors in parallel is: Rt = 1 / ( 1 / r 1 + 1 / r 2 + 1 / r 3 ) Create a variable for each o
    15·1 answer
  • What is the most important trait of the first pilot project in the AI Transformation Playbook?
    10·1 answer
  • What are some ways to rename a worksheet? Check all that apply.
    9·1 answer
  • Python exercise grade 10
    7·1 answer
  • The data model shows the_______structrue of database.​
    14·1 answer
  • Please help me!! (two questions)
    12·1 answer
  • What is a cell? how is it referred?​
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!