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
skad [1K]
3 years ago
6

. Write a short Python function that takes a sequence of integer values and determines if there is a distinct pair of numbers in

the sequence whose product is odd. (1 Point)
Computers and Technology
1 answer:
lisov135 [29]3 years ago
6 0

Answer:

Explanation:

The following code is written in Python and like requested takes a function called odd_number that takes a list of integers as a parameter. It then loops through the list two times, each time calculating the product of the two numbers and returning Yes if the product is an odd number while also including the two numbers from the list that make that product. If there is no odd product in the list the function simply returns No

def odd_product(my_list):

   for num1 in range(len(my_list)):

       for num2 in range(len(my_list)):

           if num1 == num2:

               pass

           else:

               product = my_list.__getitem__(num1) * my_list.__getitem__(num2)

               if (product % 2) != 0:

                   return "Yes, " + str(my_list.__getitem__(num1)) + " and " + str(my_list.__getitem__(num2))

   return "No"

You might be interested in
Proszę daje wszystko potrzebuje tego
Stolb23 [73]
I’m sorry I do not speak that
5 0
3 years ago
Read 2 more answers
A technician would like to have the ability to add physical hard drives to a Storage Spaces storage pool at future times on an a
Iteru [2.4K]

Answer:

b. Thin provisioning

Explanation:

Thin provisioning is a storage space feature that makes allocating disk storage space flexible based on the space needed by each user, it improves the way storage space is utilized.

5 0
3 years ago
Write a program that writes 10 random numbers into a file named numbers using loops.
MariettaO [177]

Answer:

The program in cpp for the given scenario is shown below.

#include <stdio.h>

#include <iostream>

#include <fstream>

using namespace std;

int main()

{

   //object created of file stream

   ofstream out;

   //file opened for writing

   out.open("numbers.txt");

   std::cout << "File opened." << std::endl;

   //inside for loop, random numbers written to numbers.txt using rand()

   for(int n=0; n<10; n++)

   {

       out<<rand()<<endl;

   }

   //file closed

   out.close();

   std::cout << "File closed." << std::endl;

   return 0;

}

Explanation:

1. An object of the ofstream is created. The ofstream refers to output file stream. This is used to create file for write and append operations.

ofstream out;

2. The file named, numbers.txt, is opened using the open() method with the object of ofstream.

out.open("numbers.txt");

3. The message is displayed to the user that the file is opened.

4. Inside a for loop, which executes 10 times, a random number is generated. This random number is written to the file and a new line inserted.

5. The random number is generated using rand() method. Every number is written on  new line.

out<<rand()<<endl;

6. Every execution of the for loop repeats steps 4 and 5.

7. When the loop ends, the file is closed using close() method with the object of ofstream.

out.close();

8. A message is displayed to the user that the file is closed.

9. The header file, fstream, is included to support file operations.

10. The extension of the file can be changed from .txt to any other type of file as per requirement.

11. The program can be tested for writing more numbers to the file.

12. The program can be tested for writing any type of numeric data to the file.

13. The program is written in cpp due to simplicity.

14. In other languages such as java or csharp, the code is written inside classes.

15. In cpp, all the code is written inside main() method.

16.    The screenshot of the output messages displayed is attached.

3 0
3 years ago
When do you use a for loop instead of a while loop?
creativ13 [48]

Answer:

i dont know.prob guess a short loop.

Explanation:

8 0
3 years ago
Which is NOT an event associated with the beginning of the internet
sammy [17]

Answer:

when Gandhi was born he had nothing to do with the internet. nothing can connect Gandhi to the internet.

Explanation:

Gandhi was an Indian activist who was the leader of the Indian independence movement against British colonial rule. therefore, there is no connection.

8 0
3 years ago
Other questions:
  • 8.6 Lesson Practice edhesive
    15·1 answer
  • Cameron wants to impress the owner of the company. He creates a graph that shows the improved productivity at the company over t
    13·2 answers
  • PLEASE HELP ASAP!!!!
    14·1 answer
  • As Jason walks down the street, a large raven starts squawking at him and flapping its wings. Jason thinks to himself ‘That bird
    6·1 answer
  • ____ is the use of networking technology to provide medical information and services.
    14·1 answer
  • Routing connects different network segments and decides where __________are sent to
    7·1 answer
  • In 1970, the federal government created __________ to both assist and require employers and employees to make the prevention of
    14·1 answer
  • What is the worst case time complexity of insertion sort where position of the data to be inserted is calculated using binary se
    13·1 answer
  • Comment on the following 2 arrays. int *a1[8]; int *(a2[8]); a1 is pointer to an array; a2 is array of pointers a1 is pointer to
    11·1 answer
  • What is data intergrity​
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!