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
charle [14.2K]
3 years ago
14

Write a function: function solution(N); that, given a positive integer N, prints the consecutive numbers from 1 to N, each on a

separate line. However, any number divisible by 2, 3 or 5 should be replaced by the word Codility, Test or Coders respectively. If a number is divisible by more than one of the numbers: 2, 3 or 5, it should be replaced by a concatenation of the respective words Codility, Test and Coders in this given order. For example, numbers divisible by both 2 and 3 should be replaced by CodilityTest and numbers divisible by all three numbers: 2, 3 and 5, should be replaced by CodilityTestCoders.
Computers and Technology
1 answer:
koban [17]3 years ago
6 0

Answer:

<em>The program written in Python is as follows:</em>

def solution(N):

     concat = ""

     for i in range(1,N+1):

           if not(i%2 == 0 or i%3 ==0 or i%5 == 0):

                 print(str(i))

           else:

                 if i%2 == 0:

                       concat= concat+"Codility"

                 if i%3 == 0:

                       concat= concat+"Testers"

                 if i%5 == 0:

                       concat= concat+"Coders"

                 print(concat)

                 concat = ""

N = int(input("Enter a positive integer: "))

solution(N)

Explanation:

This line declares the function

def solution(N):

This line initializes a variable named concat to an empty string

     concat = ""

This line iterates from 1 to the input integer

     for i in range(1,N+1):

<em>This line checks if the current number of iteration is divisible by 2,3 or 5, if no, the number is printed</em>

           if not(i%2 == 0 or i%3 ==0 or i%5 == 0):

                 print(str(i))

<em>If otherwise</em>

           else:

<em>This lines checks if current number is divisible by 2; if yes the string "Codility" is concatenated to string concat</em>

                 if i%2 == 0:

                       concat= concat+"Codility"

<em>This lines checks if current number is divisible by 3; if yes the string "Testers" is concatenated to string concat</em>

<em>                 </em> if i%3 == 0:

                       concat= concat+"Testers"

<em>This lines checks if current number is divisible by 2; if yes the string "Coders" is concatenated to string concat</em>

                 if i%5 == 0:

                       concat= concat+"Coders"

<em>The concatenated string is printed using this line</em>

                 print(concat)

This variable concat is intialized back to an empty string

                 concat = ""

The main method starts here

N = int(input("Enter a positive integer: "))

This line calls the defined function solution

solution(N)

You might be interested in
Super computer in nuclear energy ​
satela [25.4K]

Answer:

Dubbed “El Capitan,” the supercomputer is part of the Exascale Computing Project, a DOE effort to increase computing power so that the department can run highly advanced simulations and modelling of the United States' nuclear arsenal. These simulations help alleviate the need for underground testing.

4 0
3 years ago
What are the three general methods for delivering content from a server to a client across a network
Tju [1.3M]

Answer:

Answered below.

Explanation:

The three general methods consist of unicasting, broadcasting and multicasting.

Casting implies the transfer of data from one computer (sender) to another (recipient).

Unicasting is the transfer of data from a single sender to a single recipient.

Broadcasting deals with the transfer of data from one sender to many recipients.

Multicasting defines the transfer of data from more than one sender to more than one recipients.

8 0
2 years ago
Which of the following is not regression test case? A. A representative sample of tests that will exercise all software function
AveGali [126]

Answer:

D. Low-level components are combined into clusters that perform a specific software sub-function

Explanation:

Normally, regression testing are done on a manual basis by simply re-executing a subset of the entire available test cases or it can be done automatically by utilizing playback tools or automated capture. Hence, from the options, a combination of low-level components into clusters that perform a specific sub-function does not align with how regression testing are done either manually or automatically.

6 0
3 years ago
As it turns out, the scale of this chart is higher than all of these; it’s “exponential.” What does this imply for the difficult
Oksanka [162]

Answer:

no meme

Explanation:

[...]

8 0
3 years ago
A key step in the ____ approach to incident response is to discover the identify of the intruder while documenting his or her ac
muminat

Answer:d)apprehend and prosecute

Explanation: A intruder is a person who tries to access the system or damage it in an unauthorized manner. The person who is found with any intruding activity should be discovered.

Apprehending means of getting aware and prosecute defines the accusing of any person committing a crime .These activities define the nature of the intruder whose trying to commit the crime and should be detected while he  is pursuing the activity.Thus , the correct option is option(d).

7 0
3 years ago
Other questions:
  • Every node (except of the last node) in a singly linked list contains ____
    5·1 answer
  • Technician A says that the reserve rating of a battery is the amount of steady current that a fully charged battery can supply f
    6·1 answer
  • The stream cipher described in Definition 2.1.1 can easily be generalized to work in alphabets other than the binary one. For ma
    10·1 answer
  • Explain why it is not necessary for a program to Explain why it is not necessary for a program to be completely free of defects
    13·1 answer
  • Do you have to make a account of Windows 10?
    12·1 answer
  • Your program will search for prime numbers. You will first ask the user for the range of values to search, and use for loops to
    6·1 answer
  • You are in the windows power shell window and decide to encrypt folder which of the following command do you use
    7·1 answer
  • All states that have altered judicial selection techniques in recent years have adopted some form of:
    10·2 answers
  • 2.
    13·1 answer
  • What makes a recipe for a meal an example of an algorithm?
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!