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]
2 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]2 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
What is ASP.NET ?why is it important?
miskamm [114]
<span>ASP.NET is an open-source server-side web application framework designed for web development to produce dynamic web pages.

Without it, we would be lost on the internet, or possibly wouldn't even have internet. Whats the point of Wifi without web pages?</span>
6 0
3 years ago
AYYOOOO CAN YOU HELP A GIRL OUUTT???
goblinko [34]

Answer: The answer is true

8 0
2 years ago
An array is sorted (in ascending order) if each element of the array is less than or equal to the next element .
Aleks04 [339]

Answer:

// The program below checks if an array is sorted or not

// Program is written in C++ Programming Language.

// Comments are used for explanatory purpose

//Program Starts here

#include<iostream>

using namespace std;

//Function to check if the array is sorted starts here

int isSorted(int arr[], int count)

{

// Check if arrays has one or no elements

if (count == 1 || count == 0) {

return 1;

}

else

{

// Check first two elements

if(arr[0] >= arr[1])

{

return 0; // Not sorted

}

else

{ // Check other elements

int check = 0;

for(int I = 1; I<count; I++){

if (arr[I-1] > arr[I]) { // Equal number are allowed

check++; // Not sorted

}

}

}

if(check==0)

return isSorted(arr, count - 1); //Sorted

else

return 0; // Not sorted

}

// Main Method starts here

int main()

{

int count;

cin<<count;

int arr[count];

for(int I = 1; I<=count; I++)

{

cin>>arr[I-1];

}

int n = sizeof(arr) / sizeof(arr[0]);

if (isSorted(arr, n))

cout << "Array is sorted";

else

cout << "Array is not sorted";

}

8 0
3 years ago
What makes manually cleaning data challenging?
Alexxandr [17]

Manually cleaning data is done manually which makes it challenging. This make it prone to mistakes.

6 0
3 years ago
Which term describes the process of training a machine to do simple, repetitive tasks, and adapt or correct its performance base
yKpoI14uk [10]
Automation. ... It involves taking a machine or software that was taught to do simple repetitive tasks (traditional automation) and teaching it to intuitively adapt or correct its performance based on changing conditions, at speed and scale.
8 0
2 years ago
Other questions:
  • Assume that printStars is a function that takes one argument and returns no value. It prints a line of N stars (followed by a ne
    13·1 answer
  • When introducing new devices to the network, the organization's security policy requires that devices be monitored to establish
    15·1 answer
  • Write a program that prompts the user to enter a string (may contain spaces) and displays its last character. Enter s string: Pr
    13·1 answer
  • 6) RAM, 5 main memory<br>which storage conbe used<br>as permanent storage<br>Rom<br>a) R<br>)​
    8·2 answers
  • A commercial depicts a teenager on a skateboard vandalizing a brick wall. This is an example of:
    11·2 answers
  • All of the Internet in your country disappears. What happens next?
    13·1 answer
  • You are network administrator for an Active Directory forest with a single domain. Then network has three sites with one domain
    12·1 answer
  • 4.2 lesson practice last one plzs help
    5·2 answers
  • Question # 2
    7·1 answer
  • Hannah wants to write a book about how scientists and society interact, and she has generated ideas for chapters. Which chapter
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!