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
How does a Cloud-first strategy approach a client's migration to the Cloud?by removing outside ecosystem partners from the Cloud
belka [17]

Cloud-first strategies are <em>operating methods</em> wherein teams move all or most of their infrastructure to <em>cloud computing systems</em><em>  </em>such as Web Services, and the further discussion can be defined as follows:

  • It stores assets, including quest and <em>secure resources</em>, in the cloud rather than employing <em>physical resources</em> including such server clusters.
  • This approaches a client's migration to the <em>Cloud by integrating multiple services </em>together to serve the client's business needs.

Therefore, the final answer is "Last choice".

Learn more:

brainly.com/question/1256812

3 0
3 years ago
In Windows-based systems, a value that specifies the rights that are allowed or denied in an access control entry (ACE) of an ac
blsea [12.9K]

Answer:

C. Access mask discretionary.

Explanation:

Access_Mask is the value that defines the rights used in access control entries (ACE), this value identifies if the trustee is allowed to access a secured object.

It can define rights in three categories: Standard, specific and generic rights.

4 0
3 years ago
How can E-Commerce Portals ensure Security of online Transactions by Customers?
beks73 [17]
Ffkjlfdhaslkjfhlaksdfhlkajsdfh
6 0
3 years ago
Develop an sec (single error correction) code for a 16-bit data word. generate the code for the data word 0101000000111001. show
Kipish [7]

Answer:

code = 010100000001101000101

Explanation:

Steps:

The inequality yields 2^{k} - 1 > = M+K, where M = 16. Therefore,

The second step will be to arrange the data bits and check the bits. This will be as follows:

Bit position              number              Check bits            Data Bits

21                                   10101

20                                  10100

The bits are checked up to bit position 1

Thus, the code is 010100000001101000101

3 0
4 years ago
Read 2 more answers
After the data are appropriately processed, transformed, and stored, what is a good starting point for data mining?
Oksana_A [137]

Data visualization

Data visualization is a good starting point for data mining. There are several approaches to data mining that supports smart decisions. Data visualization places data in a visual context. It extracts the data in a clear and understandable way without any form of reading or writing. Results are displayed in the form of pie charts, graphs, and any other statistical representation. Such multidimensional views of data aid in developing a preliminary understanding of the trends that are hidden in the data set.

7 0
4 years ago
Other questions:
  • Robert brought 10 shares apex company for $18 each and later sold all of them at $17 each. This transaction resulted in what typ
    8·2 answers
  • A card ____ is a device that reads data, instructions, and information stored on flash memory cards.
    8·1 answer
  • Instructions:Select the correct answer.
    5·1 answer
  • Jim maintains attendance records for his employees for the year. Row B includes the dates of attendance, and column A includes t
    5·2 answers
  • Which task is performed by the artificial intelligence programmer?
    7·1 answer
  • Right-of-way is __________. A. guaranteed by Florida law B. the privilege of immediate use of the road C. earned by aggressive d
    15·1 answer
  • 12. Realizar un algoritmo que genere un número aleatorio, el usuario debe adivinar cual es el número generado para esto tendrá 3
    10·1 answer
  • How to create diagram that demonstrates the step<br> by step procedures in performing a mail merge.
    12·1 answer
  • How can a search be narrowed to only search a particular website????
    15·1 answer
  • pLZ PLZ PLZ HELP I HAVE SO MANY MISSING ASSINMENTS. why is physical security so important and necessary for both personal users
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!