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
The following method in Inventory is intended to count how many batteries are fully charged. What should replace /*Missing Code
OverLord2011 [107]

Trees are the most important part of our environment. They are having a direct impact on our lives. We can’t breathe except the existence of trees in the world. They leave the most important thing oxygen for us. But it is a matter of sorrow that day by day, the tendency of deforestation has been increased in the peak. It has been a matter of afraid now.

Due to the high tendency of deforestation, the world is lacking enough amount of oxygen. We need to plant more and more trees to make it normal. We have seen lots of examples that the world will face a hard time except for the existence of trees. Already, lots of species of trees have been extinct.

To fight against all the environmental odds, we need to grow more trees. The best time of growing trees is the rainy season. The soil has the best capacity to grow trees in this season. Trees have lots of uses for our regular life. We can make money and maintain our life with it. It is the biggest source of food.

If you plant lots of fruit trees, you can make a business on it. From today, we all need to start planting more and more trees.

4 0
3 years ago
IN C++
Natali [406]

Answer:

I only do Design and Technology

sorry don't understand.

4 0
3 years ago
The difference between natural and technological system
kari74 [83]
Natural systems are systems that came into being by natural processes. Like the rain cycle.

Technological systems are those to whom people intervened or designed. Like diverting water for a rider for land irrigation.
5 0
3 years ago
In a complex system, many subsystems interact with one another. How do these systems interact in terms of inputs and outputs?
Artemon [7]

Answer:

I think in there transmission you know inputs into ports like for their own

Explanation:

likeslike Spanish and is obviously inputs and outputs their portsinto the portsdifferent ports you know

4 0
3 years ago
In the Application, "The Effect of FDI on Rentals and Wages in Singapore," the annual growth rate in real rental rates for the 1
stellarik [79]

Answer:

Explanation:

Production function: In simple words, production function refers to the functional relationship between the quantity of a good produced (output) and factors of production (inputs).

Production function: In simple words, production function refers to the functional relationship between the quantity of a good produced (output) and factors of production (inputs).

FDI: A foreign direct investment is an investment in the form of a controlling ownership in a business in one country by an entity based in another country.

  • Singapore has encouraged foreign firms to establish subsidiaries within its borders, especially in the electronics industry.
  • Singapore has the fourth-largest amount of FDI in the world.
  • What has happened to the rental rate and the wage?
  • Find in the attachment a table which shows much of this.
  •    The annual growth rate in rental rates for the 1970-1990 period using the production function and marginal product was -5%.
6 0
3 years ago
Other questions:
  • The ________ of the operating system enables users to communicate with the computer system. modem window network adapter card us
    14·1 answer
  • Do you think that people have a “right” to remain anonymous online? Why or why not?
    6·1 answer
  • Pick 2 different operating systems and discuss how they can be used in daily operations.
    5·1 answer
  • Which of the following code is correct? I: print("Programming is fun") print("Python") print("Computer Science") II: print("Prog
    11·1 answer
  • Sean works for a company that ships hospital equipment. He needs to calculate the weight of the items being shipped. He enters t
    12·1 answer
  • Does "remainder of x from y" mean xmody?
    5·1 answer
  • What are the fundamental activities that are common to all software processes?
    9·1 answer
  • According to Okun's law, if the unemployment rate goes from 7% to 4%, what
    15·1 answer
  • The page that appears when you first open your Internet browser is the _____.
    8·1 answer
  • Assume that an int variable age has been declared and already given a value. Assume further that the user has just been presente
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!