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
I NEED HELP!!! BRAINLIEST!!!
Trava [24]

Answer:

DHCP Dynamic Host Configuration Protocol:

Is a network service that automatically assigns IP addresses and other TCP/IP configuration information on network nodes configured as DHCP clients. Server allocates IP addresses to DHCP clients dynamically. Should be configured with at least one DHCP scope. Scope contains a range of IP addresses and a subnet mask, and can contain other options, such as a default gateway and Domain Name System. Scope also needs to specify the duration of the lease and usage of an IP affects after which the node needs to renew the lease with the SHCP server. Determines the duration, which can be set for a defined time period or for an unlimited length of time.

DNS Domain Name Service: Is a TCP/IP name resolution service that translates FQDNs into IP addresses. System of hierarchical databases that are stored on separate DNS servers on all networks that connect to the Internet. DNS servers store, maintains and update databases, they respond to DNS client name resolution requests to translate host names into IP addresses.

DNS Components

DNS database is divided logically into a heieratchical grouping of domains. Physically into files called zones. Zone files contain the actual IP-to-host name mapping for one or more domains. Zone files is stored on the DNS server that is responsible for resolving hot names for the domains contained in the zone. Each network node in that domain will have a host record within the domain's zone files. Includes the node's host name, FQDN, and assigned IP address.

DNS Servers

*If you are configuring static IP addresses, including the IP address of the default DNS servers as you configure each client.

*If you are using DHCP, use the DHCP scope options to specify the IP Explanation:

3 0
2 years ago
Read 2 more answers
What is the boundary folding method?
Romashka [77]

Answer:

 Boundary folding method is basically used in the java algorithm and in the hash table. In the hash function, the left and the right value are basically folded in the fixed boundary between the given center values by using the boundary folding methods.

There are basically two types of folding method in the hashing that are:

  • Folding shift
  • Folding boundary

In the folding boundary method the outside value are get reversed and the alternate values are get flipped at the boundary folding method.

4 0
3 years ago
Whats the best way to get into a computers programming to get past firewalls
raketka [301]

you can use the software psiphon

6 0
2 years ago
Read 2 more answers
In what year did alienware introduce alienfx lighting zones into their pc's?
ser-zykov [4K]
The answer to the question asked  above is 2006. 
<span>Alienware introduce alienfx lighting zones into their pc's on 2006.</span>

Hope my answer would be a great help for you.    If you have more questions feel free to ask here at Brainly.
8 0
3 years ago
The collection of all component frequencies iscalled _____________
yKpoI14uk [10]

Answer:

The answer is Frequency Spectrum.

Explanation:

The frequency spectrum is range of all component frequencies.It contains all the waves which are as following:-

Gamma Rays

X-Rays

Ultraviolet

Visible light.

Infrared

Micro wave

Radio wave

These all waves have their range of frequencies.The waves that are visible to us is only the visible light.

4 0
3 years ago
Other questions:
  • Many shops are simply plugging up their drains to keep from inadvertently violating the law and creating environmental contamina
    15·1 answer
  • Write an examples of Output device, storage devices and inputs device 10 each excluding the common ones​
    5·1 answer
  • A technician is configuring a new SOHO multifunction wireless router at a customer's location to provide network access to sever
    7·1 answer
  • Declaring single arrays is done with a0 set(s) of straight brackets.
    10·1 answer
  • In your own words, describe what Internet Protocols are. Why is it important to have agreed upon protocols?
    6·1 answer
  • The ____ allows a core to communicate with other cpu components, such as the memory controller and other cores
    14·1 answer
  • ______ is a disadvantage of EDI.
    8·1 answer
  • To add a new kind of information into the database you need to add a new table<br> true or false?
    7·2 answers
  • When evaluating the validity of a website beyond its URL, you can practice the "rule of 3" which means
    11·2 answers
  • how to create use an array of Course objects instead of individual objects like course 1, course 2, etc
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!