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
Archy [21]
2 years ago
10

Write a program that prints the sum of the even numbers and the products of odd numbers on the screen

Computers and Technology
1 answer:
ss7ja [257]2 years ago
4 0

Answer:

The program in Python is as follows:

n = int(input("Number of inputs: "))

total = 0; product = 1

for i in range(n):

   num = int(input(": "))

   if num%2 == 0:

       total+=num

   else:

       product*=num

print("Sum of even: ",total)

print("Product of odd: ",product)

Explanation:

This prompts the user for the number of inputs, n

n = int(input("Number of inputs: "))

This initializes sum (total) to 0 and products to 1

total = 0; product = 1

This iterates through n

for i in range(n):

This gets the inputs

   num = int(input(": "))

If input is even, calculate the sum

<em>    if num%2 == 0:</em>

<em>        total+=num</em>

If otherwise, calculate the product

<em>    else:</em>

<em>        product*=num</em>

Print the required outputs

<em>print("Sum of even: ",total)</em>

<em>print("Product of odd: ",product)</em>

<em />

You might be interested in
HELP!!! What would var d=?
sergiy2304 [10]

Answer:

51015

Explanation:

Var b is a string, and it'll treat addition like <em>string concatenation </em>(aka just adding a message.) Since it's concatenation, it'll then turn the numbers/integers into strings.

This kind of behavior might be different depending on the language, though. Some languages might not allow this. (For example, C and C++)

7 0
3 years ago
HOW IS THE AUTOFILL FEATURE HELPFUL? A.IT CREATE A NEW FORMULA FOR EVERY CELL IN THE DOCUMENT B.IT CAN SAVE TIME BY ALLOWING YOU
bulgar [2K]
B. it can save time by allowing you to quickly fill cells
4 0
3 years ago
Assignment 1 silly sentences
ololo11 [35]

Answer:

Sally sells sea shells by the sea shore

Explanation:

3 0
3 years ago
Ruby is a graduate fresh out of a fashion school in New York. Ruby is not very interested in finding work in a fashion house. In
Lelu [443]
Ruby can take up movie design in flim television ' or theater production
7 0
3 years ago
Social media has evolved rapidly in this digital era, from email and text messages to instant updates, image sharing, and media
Sidana [21]
Bro no one is going to help you write a two page report do it yourself are you that lazy?
6 0
3 years ago
Other questions:
  • Show the subnet address, subnet mask in slash notation, broadcast address, number of addresses, first valid host address, and th
    13·1 answer
  • What is the internet?
    5·2 answers
  • In which type of market do farmers sell their produce directly to village traders in rural areas?
    14·1 answer
  • Print "Censored" if userInput contains the word "darn", else print userInput. End with newline. Ex: If userInput is "That darn c
    5·1 answer
  • Explain briefly the purpose of the Computer Management Console in Microsoft Windows.
    12·1 answer
  • Which of the following best explains the different between Cut and Copy? a. When you copy text you are permanently deleting it,
    5·2 answers
  • You are a network engineer tasked with performing a site survey for a multiple-channel architecture (MCA) system in a three-stor
    11·1 answer
  • The blank provides access to the internet May also be internal ??
    14·1 answer
  • How are keyboards applied in the real world
    13·1 answer
  • A timer is set after each frame is sent before waiting an ACK for that frame, how long does the timer take to be expired?
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!