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
Andrew has invested in a new CAD system to use in his workshop. What changes have occurred because he adopted the new system?
Bad White [126]

Answer:

B.   CAD produces designs that are of the highest quality.

C.   CAD provides systems for error-free manufacturing.

Explanation:

B.   CAD produces designs that are of the highest quality.

CAD does produce the highest quality of design, way better than what traditional paper plans can do.

C.   CAD provides systems for error-free manufacturing.

Many manufacturing systems can read CAD designs directly before the need of a human intervention in between, that eliminates possible errors.

Answers A and D are not true, because once passed the learning-curve, CAD greatly accelerates the production of designs.  And we know the learning-curve is behind them because the question says he has adopted the new system.

5 0
3 years ago
Read 2 more answers
Given A=1101 and B=1001. What is the result of the boolean statement: A<br>AND B​
attashe74 [19]

Answer:

B  (1001)

Explanation:

The AND operator gets you 1's where there are 1's in both inputs. So if you would "overlay" the two binary values, only 1001 remains.

5 0
2 years ago
Give differensess between Container element and empty element in computer please give answer Help​
k0ka [10]

Answer:

The answer to this question is given below in the explanation section.

Explanation:

There are containers and empty elements or tags in computer discipline such as in HTML language.  

Empty element:

These are the elements are the tags that have no content inside them and these elements or tags do not have end tags. for example the break tag in HTML such as <br> etc.

Container elements or tags:

These elements or tags have content inside them, they have opening and closing tags, unlike empty tags. for example paragraph tag, bold tag, and italic tag. These tags have opening and as well as closing tags. and between them, there is some content inside them.

the example of container tags is given below:

  • <html> html code / html contents</html>
  • <p>this is a<b>pargraph</b>container</p>

7 0
3 years ago
Does anybody have the code to 2.19.4: Guess a Number 2.0 in codeHS??
Tcecarenko [31]

Answer:

speed(0)

secret_number = 9

pensize(10)

def green_check():

   color("green")

   penup()

   backward(25)

   right(45)

   pendown()

   forward(35)

   left(90)

   forward(75)

   

def draw_arrow():

   color("red")

   left(90)

   forward(50)

   left(45)

   backward(25)

   forward(25)

   right(90)

   backward(25)

   forward(25)

   left(45)

   backward(100)

   forward(50)

   right(90)

   

user_number = int(input("Guess a number between 1 and 10: "))

while user_number != secret_number:

   if user_number < secret_number:

       draw_arrow()

   else:

       left(180)

       draw_arrow()

       right(180)

   user_number = int(input("Guess a number between 1 and 10: "))

   clear()

   

green_check()speed(0)

secret_number = 9

pensize(10)

def green_check():

   color("green")

   penup()

   backward(25)

   right(45)

   pendown()

   forward(35)

   left(90)

   forward(75)

   

def draw_arrow():

   color("red")

   left(90)

   forward(50)

   left(45)

   backward(25)

   forward(25)

   right(90)

   backward(25)

   forward(25)

   left(45)

   backward(100)

   forward(50)

   right(90)

   

user_number = int(input("Guess a number between 1 and 10: "))

while user_number != secret_number:

   if user_number < secret_number:

       draw_arrow()

   else:

       left(180)

       draw_arrow()

       right(180)

   user_number = int(input("Guess a number between 1 and 10: "))

   clear()

   

green_check()

Explanation:

It's right

6 0
3 years ago
What can cause noise?
Mkey [24]

Answer:

All of the above

Explanation:

It al depends on the type of questions

3 0
3 years ago
Read 2 more answers
Other questions:
  • What is faster a hi-speed usb port or superspeed usb port?
    13·1 answer
  • Ng/ Computer Applications - Office 2016 - EL3520 A
    13·1 answer
  • Which of the follow will happen if you miss a monthly credit card payment?
    11·1 answer
  • Given the following while() loop, which statement is true assuming A,B,C,D are int variables and A &gt; B? while ( ( A &gt;= B)
    8·1 answer
  • What does start immediately after the work is created and fixed into physical or digital form?
    10·2 answers
  • Which function of NOS involves swapping programs and files
    6·1 answer
  • The beginning statement of a loop is called a declaration.<br> True<br> False
    10·2 answers
  • What is Roko's Basilisk?
    7·1 answer
  • What is the name of the User-defined function that is mentioned in the code?
    6·1 answer
  • If you double the force of and object what happens to the acceleration
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!