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]
1 year 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]1 year 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
In order to be compliant with the NIST publications, policies must include key security control requirements. One of these key r
lesya692 [45]

Answer:

True

Explanation:

In order to be compliant with the NIST publications, policies must include key security control requirements. One of these key requirements includes certification and accreditation, which is a process that occurs after the system is documented, controls tested, and risk assessment completed. It is required before going live with a major system. Once a system is certified and accredited, responsibility shifts to the owner to operate the system is a true statement.

8 0
3 years ago
What is the name used for the camera s view from a single position?
CaHeK987 [17]
The answer to your question is a shot


6 0
3 years ago
You are given an array of integers, each with an unknown number of digits. You are also told the total number of digits of all t
Vlad [161]

Answer:

Explanation:

Since all of the items in the array would be integers sorting them would not be a problem regardless of the difference in integers. O(n) time would be impossible unless the array is already sorted, otherwise, the best runtime we can hope for would be such a method like the one below with a runtime of O(n^2)

static void sortingMethod(int arr[], int n)  

   {  

       int x, y, temp;  

       boolean swapped;  

       for (x = 0; x < n - 1; x++)  

       {  

           swapped = false;  

           for (y = 0; y < n - x - 1; y++)  

           {  

               if (arr[y] > arr[y + 1])  

               {  

                   temp = arr[y];  

                   arr[y] = arr[y + 1];  

                   arr[y + 1] = temp;  

                   swapped = true;  

               }  

           }  

           if (swapped == false)  

               break;  

       }  

   }

8 0
2 years ago
Gary lives in an area that receives high rainfall throughout the year. Which device would be useful to him to maintain his compu
-BARSIC- [3]

The correct answer is B.UPS

A UPS or Uninterruptable Power supply makes sure that you have backup in case there is a power outage in your area. It provides ample time for you to save all files before shut down.

6 0
3 years ago
Read 2 more answers
Can I have help on this
never [62]

the answer is the seconf one


6 0
3 years ago
Read 2 more answers
Other questions:
  • Given a int variable named yesCount and another int variable named noCount and a char variable named response, write the necessa
    9·1 answer
  • The likelihood of the occurrence of a vulnerability multiplied by the value of the information asset - the percentage of risk mi
    12·1 answer
  • It is okay to use a dust rag when cleaning the inside of a computer.
    9·2 answers
  • Can you please answer these questions for me: Is it illegal to copyright? What does it mean to get copyrighted? What are example
    12·2 answers
  • Terms that represents the achual speed used by device to transfer data​
    14·1 answer
  • How to Save Power-Point presentation as a single file Web page that can be uploaded to the World Wide Web ?
    14·1 answer
  • Mobile computing has two major characteristics that differentiate it from other forms of computing. What are these two character
    8·1 answer
  • In Python please:
    12·1 answer
  • Which are technical and visual demands that need to be considered when planning a project? Choose three answers
    10·1 answer
  • Anyone else like hunter x hunter?<br> lets talk abt it uwu<br><br> good day :)
    14·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!