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
-) An attribute is a(n)?
Anarel [89]
<h3>An attribute is a characteristic.In a data base management system,an attribute refers to a database component,such as a table.It also may refer to a database field.</h3>

6 0
3 years ago
Why does the font­family css specification take a list rather than a single font name?
azamat
You can't guarantee that the computer displaying the page has all the fonts that you want. Generally for font-family (note the hyphen!) you list:

the font you REALLY want
a font that's similar and more common (you HOPE it has)
the family (like serif or san-serif)
5 0
4 years ago
Class 00 rubber gloves are used when working with voltages less than​ _____.
Radda [10]
Answer: 500 volts AC, 750 volts DC
Class 00 rubber gloves are given the color "beige" based on the color code of rubber gloves.
The proof test voltage for this class of rubber gloves is 2500 volts of AC voltage and 10000 volts of DC voltage
4 0
3 years ago
1
Effectus [21]

Answer:

1. Modularity.

2. Refinement.

3. Structural partitioning.

4. Data Structure.

Explanation:

A software development life cycle (SDLC) can be defined as a strategic process or methodology that defines the key steps or stages for creating and implementing high quality software applications. There are six (6) main stages in the creation of a software and these are;

1. Planning.

2. Analysis.

3. Design.

4. Development (coding).

5. Deployment.

6. Maintenance.

One of the most important steps in the software development life cycle (SDLC) is design. It is the third step of SDLC and comes immediately after the analysis stage.

Basically, method design is the stage where the software developer describes the features, architecture and functions of the proposed solution in accordance with a standard. Some of the models or techniques used in the design of a software are;

  • Modularity: refers to the concept that software architecture has the ability to divide into modules and that each
  • module can be examined independently.
  • Refinement: is a process that elaborates on each design component until it reaches the coding details.
  • Structural partitioning: allows designers to split a program structure horizontally and vertically.
  • Data Structure: represents logical relationships between individual data elements.
4 0
3 years ago
In the range E7:E11, apply the Currency number format with zero decimal places and $ as the symbol.
lisabon 2012 [21]

Answer:

bt wheres the data

Explanation:

6 0
3 years ago
Other questions:
  • Which best describes a computer bug? A piece of computer hardware that is out of date or has a newer version a piece of computer
    14·2 answers
  • What is the output of the following program fragment? int alpha [ 5 ] = {100, 200, 300, 400, 500}; int i; for (i = 4; i &gt; 0;
    6·1 answer
  • If you're found to be at fault in _____, your driver license will be canceled within 90 days unless you complete a 12-hour Advan
    10·2 answers
  • What will you personally do to make your peers aware of the seriousness Of teen crashes?
    9·1 answer
  • Explain how the operating system controls the software and hardware on the computer?
    5·1 answer
  • With the _______ network topology, reliability is the major advantage while high cost is the disadvantage.
    13·1 answer
  • PLEASE FASTTTTT
    8·2 answers
  • Join my among us <br><br> code GNLMJF
    13·2 answers
  • ____ is an easy way to invitation through a web page​
    12·2 answers
  • It is most commonly used for self-running presentations.
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!