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
List three different computer languages, and describe how each one is used in software development
Bumek [7]
JavaScript- Used in designing websites

Python- Used in developing desktop and web applications

C++ Used in Video games, operating systems such as Windows 10, and device drivers.
6 0
3 years ago
How the full address space of a processor is partitioned and how each partition is used?
Sati [7]

Answer:

?

Explanation:

?

6 0
3 years ago
Under which jeys do the page up and page down keys fall under
Mademuasel [1]

Answer:

Page up(PgUp) and Page down(PgDn) keys fall under the navigation keys.

Explanation:

Page up(PgUp) and Page down(PgDn) keys fall under the navigation keys.

They include the four Arrow keys, Page Up, Page Down, Home and End keys.

<u>Arrow Keys:</u>

One of four computer keys marked with an up, down, left, or right arrow, used for moving the cursor.

<u>Page Up and Page down:</u>

Page Up and Page Down keys abbreviated as PgUp and PgDn are two keys commonly found on computer keyboards. The two keys are used to scroll up or down in documents.

<u>Home Key:</u>

The Home key is used to return the typing cursor to the beginning of the line on which you are currently typing.

<u>End Key:</u>

The end key is opposite to home key. It is used to return the typing cursor to the end of the line on which you are currently typing....

4 0
3 years ago
________ uses statistical techniques to explore records in a data warehouse by hunting for hidden patterns and relationships tha
Ulleksa [173]
The answer is Data Warehousing
8 0
3 years ago
How is gawain tempted​
jeyben [28]

Answer:

Sir Gawain and the Green Knight book cover

MENU

What are the temptations of Sir Gawain in "Sir Gawain and the Green Knight"?

print Print document PDF list Cite

Expert Answers info

HILLARD THIEL eNotes educator | CERTIFIED EDUCATOR

In addition to the obvious temptations in Berkilak's castle with his wife (all of which involve erotic temptation and the temptation to violate hospitality for personal pleasure), more significant spiritual temptations frame this story. First, Gawain displays an element of pride when he agrees to participate in the initial contest. While Arthur is more to blame and Gawain offers to take his place, it certainly is not prudent to participate in this contest with a character whose appearance suggests that he is not a normal, mortal man. The first part of this bargain therefore involves the temptation of pride.

r Gawain and the Green Knight by Pearl-Poet

Sir Gawain and the Green Knight book cover

MENU

What are the temptations of Sir Gawain in "Sir Gawain and the Green Knight"?

print Print document PDF list Cite

Expert Answers info

HILLARD THIEL eNotes educator | CERTIFIED EDUCATOR

In addition to the obvious temptations in Berkilak's castle with his wife (all of which involve erotic temptation and the temptation to violate hospitality for personal pleasure), more significant spiritual temptations frame this story. First, Gawain displays an element of pride when he agrees to participate in the initial contest. While Arthur is more to blame and Gawain offers to take his place, it certainly is not prudent to participate in this contest with a character whose appearance suggests that he is not a normal, mortal man. The first part of this bargain therefore involves the temptation of pride.

Later, the temptation that most condemns Gawain is the desire to continue living even if one will live a life compromised by deceit. While it is understandable that Gawain would hide the garter and flinch at the blow of an ax, the temptation to focus on his mortal rather than his spiritual life is the cause of his wearing the garter as a mark of shame.

Explanation:

6 0
3 years ago
Other questions:
  • Tamara has $500 she is looking to save for a class trip. She wants to earn the most possible interest and will not need access t
    13·2 answers
  • Which of the following are you likely to find between multiple school buildings in a city wide school district?
    9·1 answer
  • How do I change the year I was born on this website? I made a mistake and now I can't fix it. Can somebody please help me?
    5·1 answer
  • The ____ aggregate function finds the largest value
    10·1 answer
  • Does the brain play a role in smartphone addiction
    7·2 answers
  • Which Tab contains the font style attributes?<br><br> Home<br> Insert<br> Review<br> View
    8·2 answers
  • A project manager is responsible for (check all that apply)
    13·1 answer
  • In a meeting, Juan hears someone say a product mix is "wide." What does
    13·1 answer
  • Which of the given original work is protected by the copyright law?
    5·1 answer
  • CALLING ALL DEKUS UWU
    15·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!