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
mixer [17]
3 years ago
5

g write a recursive function that prints out all the even numbers between x and y inclusive if x is odd then the print out will

start at x 1
Computers and Technology
1 answer:
Reil [10]3 years ago
3 0

Answer:

The function written in python is as follows:

def EvenNumbers(x, y):

    if (y < x):

         return

    if (y % 2 == 0):

         EvenNumbers(x, y - 2)

    else:

         EvenNumbers(x, y - 1)

    if (y % 2 == 0):

         print(y)

Explanation:

x represents the lower limit while y represents the upper limit.

So, the recursion will be repeated as long as x <= y

This defines the function

def EvenNumbers(x, y):

This checks if y < x. If yes, the recursion stops execution and return to the main

<em>     if (y < x): </em>

<em>          return </em>

The following if and else condition checks determines the appropriate range of the recursion.

<em>     if (y % 2 == 0): </em>

<em>          EvenNumbers(x, y - 2) </em>

<em>     else: </em>

<em>          EvenNumbers(x, y - 1) </em>

The above takes care of printing starting at x + 1 if x is odd

This checks and prints the even numbers in the range

<em>     if (y % 2 == 0): </em>

<em>          print(y)</em>

<em />

To call the function from main, make use of

EvenNumbers(x, y)

Where x and y are integers

e.g EvenNumbers(2,10), EvenNumbers(1,17), EvenNumbers(3,21)

<em>See attachment</em>

You might be interested in
JAVA QUESTION::
allochka39001 [22]

Answer:

3) 44 10 44

Explanation:

Given data

int [] val = { 3, 10, 44 };

The total number of parameters of given array are 3, so total length of array is also 3.

The indexing of array starts with '0', Therefore the <u>indexes</u> of array with length zero are: {0,1,2}

The value of array at index 0 is = 3

similarly

value at index 1 = 10

value at index 2 = 44

Any value of index 'i' of an array is selected using array[i].

Therefore,

val[0] is selecting the value of array located at index '0'.

val[0] = 3

val[2] is selecting the value of array located at index '2'.

val[2] = 44

Finally,

val[0] = val[2]; is copying the value placed at index 2 (44) to value placed at index 0 (3). Hence, the output would be { 44 10 44}. So 3rd option is correct.

 

8 0
4 years ago
Anomaly detection systems make use of _______________ that describe the services and resources each authorized user or group nor
zhuklara [117]

Answer:

profiles

Explanation:

<h2><u>Fill in the blanks </u></h2>

Anomaly detection systems make use of <u> profiles</u> that describe the services and resources each authorized user or group normally accesses on the network.

5 0
3 years ago
A type of authentication that requires the user to provide something that they know, such
bagirrra123 [75]
The answer would be true
5 0
3 years ago
How data transform into information?​
laila [671]
Information is when you take the data you have and analyze it or manipulate it by combining it with other data, trending it over time, assessing or analyzing the outliers that need to be dealt with, and, most important, applying your own experience and knowledge to transform that data into something you can use to make
4 0
3 years ago
Match the OOP concept to its definition.
Alekssandra [29.7K]

Answer:

defines a class in terms of another class = inheritance

inherits the properties of a base class = derived class

provides only essential information to the world = data abstraction

binds data and functions together = encapsulation

Explanation:

6 0
3 years ago
Other questions:
  • In what era did plants begin to flourish?
    9·1 answer
  • What did I do wrong? May you please correct it for me...I was also looking on how to delay when it prints. Like when it prints a
    9·1 answer
  • What special skill does a developer need to thelp produce timely solutions for users
    7·1 answer
  • What e-mail protocol does Marina and Rita’s Cupcakes use and why is it important?
    5·1 answer
  • Which step of the laser printer imaging process requires troubleshooting if a printer produces ghost images on output pages?
    13·1 answer
  • When coding using the root operation Detachment, the term "ray" is used to describe a particular part of the hand and foot. What
    14·1 answer
  • Join my among us code<br> SHUHZF
    6·2 answers
  • 3.<br>What is the meaning of *.VBP.<br>​
    6·2 answers
  • 8.10 Code Practice Question 1
    12·1 answer
  • 2. 25 POINTS!!!!!!!!!
    8·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!