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
Marina CMI [18]
2 years ago
5

9.18 lab: even/odd values in a vector write a program that reads a list of integers, and outputs whether the list contains all e

ven numbers, odd numbers, or neither. the input begins with an integer indicating the number of integers that follow. ex: if the input is 5 2 4 6 8 10, the output is: all even ex: if the input is 5 1 3 5 7 9, the output is: all odd ex: if the input is 5 1 2 3 4 5, the output is: not even or odd your program must define and call the following two functions. isvectoreven returns true if all integers in the array are even and false otherwise. isvectorodd returns true if all integers in the array are odd and false otherwise. bool isvectoreven(vector myvec) bool isvectorodd(vector myvec)
Computers and Technology
1 answer:
lana66690 [7]2 years ago
6 0

def is_list_even(my_list):

   for i in my_list:

       if(i%2 != 0):

           return False

   

   return True

   

   

def is_list_odd(my_list):

   for i in my_list:

       if(i%2 == 0):

           return False

   

   return True

   

def main():

   n = int(input())

   lst = []

   

   for i in range(n):

       lst.append(int(input()))

   

   if(is_list_even(lst)):

       print('all even')

   

   elif(is_list_odd(lst)):

       print('all odd')

   

   else:

       print('not even or odd')

       

       

if __name__ == '__main__':

   main()

You might be interested in
Given the String variables name1 and name2, write a fragment of code that assigns the larger of the two to the variable first (a
Neporo4naja [7]

Answer:

if ( name1 > name2) {

    first = name1;

} else {

    first = name2;

}

Explanation:

First you need take a decision for that reason you need and if - else structure to decide if asign the variable name1 or the variable name2 to the result. Later you can use an > or < to compare two strings because it use the ASCII code to compare wich one is larger than another.

if ( name1 > name2) {

    first = name1;

} else {

    first = name2;

}

6 0
3 years ago
Based on the condition.
e-lub [12.9K]

Answer:

A subroutine is a block of statements that carries out one or more tasks. ... they share all variables with the rest of the main program. ... Once you have defined a function in your program, you may use it in any appropriate expression, such as: ... Thus, functions can- not change the values of the arguments passed to them.

Explanation:

5 0
3 years ago
What is the process in which a server is partitioned into smaller components virtually
lilavasa [31]

The answer to your question is,

Server virtualization

-Mabel <3

3 0
3 years ago
Acess labeling windows​
Debora [2.8K]

Answer:

I got the same thing

Explanation:

8 0
3 years ago
Businesses around the world all need access to the same data, so there
Alexxx [7]

Answer:

B

Explanation:

3 0
2 years ago
Other questions:
  • Which group on the sparkline tools design tab would you choose if you wanted to change the data source of the sparkline? (1 poin
    10·1 answer
  • What cable should i be using to connect my android tablet to the pc?
    13·2 answers
  • For which of the following careers is technology’s connectivity factor most important?
    13·2 answers
  • Which is an unethical use of technology and resources at the workplace?
    13·2 answers
  • Online banking tools allow you to pay bills from your computer. <br> a. True<br> b. False
    5·2 answers
  • Why are medical related professions and human resources important? ​
    8·1 answer
  • What is the work of the cpu as processer
    6·2 answers
  • What is another word for: a location in memory that contains a value? A. integer B. Boolean C. variable D. float PLEASE HELP URG
    10·1 answer
  • How would I collect a number from the user to use for the radius of a circle?
    13·1 answer
  • Q1) write a brief note on desktop computer.
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!