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

Answers

Answer 1

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

    if (y < x):

         return

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

    if (y % 2 == 0):

         EvenNumbers(x, y - 2)

    else:

         EvenNumbers(x, y - 1)

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

This checks and prints the even numbers in the range

    if (y % 2 == 0):

         print(y)

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)

See attachment

G Write A Recursive Function That Prints Out All The Even Numbers Between X And Y Inclusive If X Is Odd

Related Questions

4
Multiple Choice
You wrote a program to find the factorial of a number. In mathematics, the factorial operation is used for positive integers and zero.
What does the function return if the user enters a negative three?
def factorial number):
product = 1
while number > 0
product = product number
number = number - 1
return product
strNum = input("Enter a positive integer")
num = int(str Num)
print(factorial(num))
O-6
O-3
O There is no output due to a runtime error.
0 1
< PREVIOUS
NEXT >
SAVE
SUBMIT
© 2016 Glynlyon, Inc. All rights reserved.
V6.0 3-0038 20200504 mainline

Answers

The function will output positive 1 to the console. This happens because we declare product as 1 inside our function and that value never changes because the while loop only works if the number is greater than 0.

Write a program that prompts the user to enter a Social Security number in the format ddd-dd-dddd, where d is a digit. The program displays Valid SSN for a correct Social Security number or Invalid SSN otherwise.

Answers

ssn = input("Enter a valid Social Security number: ")

dashes = 0

nums = 0

message = "Invalid SSN"

if len(ssn) == 11:

   for x in ssn:

       if x.isdigit():

           nums += 1

       elif x == "-":

           dashes += 1

if nums == 9 and dashes == 2:

   message = "Valid SSN"

print(message)

I wrote my code in python 3.8. I hope this helps!

The program that prompts the user to enter a Social Security number in the format ddd-dd-dddd, where d is a digit can be implemented in Python using regular expressions. The regular expression pattern for the SSN format can be used to validate the input.

Pythons code:

```python

import re

ssn_pattern = re.compile(r'^\d{3}-\d{2}-\d{4}$')

ssn = input("Enter your Social Security Number (format: ddd-dd-dddd): ")

if ssn_pattern.match(ssn):

print("Valid SSN")

else:

print("Invalid SSN")

```

In the above code, we first import the `re` module to work with regular expressions.

We then define the regular expression pattern for the SSN format as `^\d{3}-\d{2}-\d{4}$`. This pattern matches any string that starts with three digits, followed by a hyphen, then two digits, another hyphen, and finally, four digits.

We then prompt the user to enter their SSN using the `input()` function. We then check if the entered SSN matches the pattern using the `match()` function of the regular expression object `ssn_pattern`.

If the SSN matches the pattern, we print "Valid SSN". Otherwise, we print "Invalid SSN".

Know more about SSN,

https://brainly.com/question/31778617

#SPJ4

The Review tab in Microsoft Publisher provides two groupings called _____. Proofing and Language Spell Check and Research Proofing and Thesaurus Language and Comments

Answers

Answer:

Proofing and language.

Explanation:

Environmental ____ include disturbances in the external environment.​

Answers

Answer:What are external environmental factors?

Customers, competition, economy, technology, political and social conditions, and resources are common external factors that influence the organization. Even if the external environment occurs outside an organization, it can have a significant influence on its current operations, growth and long-term sustainability.

Explanation:

3. Describe what is happening in this code

import java.util.Scanner;

public class WordFinder {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
System.out.println ("Please enter a word");
String usrWord = s.nextLine();
String alph = ("ABCDEFGHIJKLMNOPQRSTUVWXYZ");

for(int i = alph.length () - 1; i >= 0; i--){
System.out.println(alph.charAt (i) + usrWord);

}
}
}

Answers

Answer:

Prints out the word a user has inputted once for each letter of the alphabet string, with the letter (starting from "Z") and the word together.

Explanation:

Hi there! I program in C# and javascript mainly but I'm pretty sure I can see what's happening here. :)

Scanner is used to get user input.

We import the library at the top so that we can use it.

Inside main in the WordFinder class we create a new instance of the Scanner object so we can use it to get input. We assign this to the variable "s".

On the next line we use System.out.printIn to print a message that asks the user to enter a word.

On the next line we use s.nextLine() ("s" to reference the Scanner) to get the input from the user and we assign the string to the String type variable called "usrWord".

On the next line we assign a string that is all capital letters of the alphabet to a String type variable called "alph".

Under this, we create a for loop

"i" is the length of the alph string minus one (so 25, it doesn't need to be 26 as java uses zero-based indexing which is just a fancy way to say counting starts at 0 instead of 1)

The for loop says that while "i" (starting from 25) is more than or equal to 0, to minus 1 from "i".

For each time it does this, it cycles through each letter of the alphabet string backwards (because we're starting at 26 printing the letter and the word as one string each time.

(charAt is a method that returns the character at the index number in the string it is given btw)

Example output of the code, if the user inputs the word "cat", it would print:

Zcat

Ycat

Xcat

Wcat

Vcat

(and so on, you get the picture)

Let me know if you need any of that clearing up! :)

Hope that helps!

Answer:

lol

Explanation:

You have the opportunity to meet some droids and Wookies! Prompt the user for their name, then how many droids, and then how many Wookies they want to meet. Print out the name that was given, as well as how many droids and Wookies they wanted to meet. Here is an example of what you should print: Sean wants to meet 3 droids and 2 Wookies.

in phyton code

Answers

name = input("What's your name? ")

droids = int(input("How many droids do you want to meet? "))

wookies = int(input("How many wookies do you want to meet? "))

print(name + " wants to meet "+str(droids)+" droids and "+str(wookies)+" Wookies.")

I wrote my code in python 3.8. I hope this helps!

power point programm

Answers

huhhhhhhhyyyyhheyeydud

What can be harmful to your computer?

Mobile Devices
Fogd and Drinks
Respect
Cyberbullying

Answers

Answer:

B, Food and Drinks......

Environmental include disturbances in the external environment.​

Answers

Answer:

from what i know, Stuff like corona and no air can disturb the Environment.

HELP PLEASE

Today, not only do companies employ public relations managers but so do many
celebrities and politicians. Research and explain what the role of a public relations
manager is and see if you can think of the reasons why many public figures seem
to find them useful.

Answers

Answer: The role of a public relations manager is to keep the image of a celebrity, politician, ect. good so that they can keep their career going while constantly in the eye of the public. Public figures may find this useful because it can help them keep their record clean and have a personal life while also making it seem like they are perfect people to their audience, which in hand can help with business.

Explanation:

Order the steps for the correct path to adding defined names into a formula. Enter an equal sign into the cell. Type an open parenthesis and enter named cells instead of location. Type the function in caps.

Answers

Answer: Enter equal sign into the cell, Type the function in caps, and Type an open parenthesis and enter names cells instead of location.

Explanation: It's the correct order.

Answer:

Enter an equal sign into the cell

Type the function in caps

Type an open () and enter named cells instead of location

Explanation:

Create a script to input 2 numbers from the user. The script will then ask the user to perform a numerical calculation of addition, subtraction, multiplication, or division. Once the calculation is performed, the script will end.

Answers

Answer:

The code given is written in C++

First we declare the variables to be used during the execution. The names given are self-explanatory.

Then the program outputs a request on the screen and waits for user input, for both numbers and one more time for the math operation wanted, selected with numbers 1 to 4.

Finally, the program executes the operation selected and outputs the result on screen.  

Code:

#include <iostream>

int main()

{

// variable declaration

float numberA;

float numberB;

int operation;

float result=0;

//number request

std::cout<<"Type first number:\n"; std::cin>>numberA;

std::cout<<"Type second number:\n"; std::cin>>numberB;

 

//Operation selection

cout << "Select an operation\n";

cout << "(1) Addition\n";

cout << "(2) Subtraction\n";

cout << "(3) Multiplication\n";

cout << "(4) Division\n";

std::cout<<"Operation:\n"; std::cin>>operation;

switch(operation){

 case 1:

  result = numberA+numberB;

  break;

 case 2:

  result = numberA-numberB;

  break;

 case 3:

  result = numberA*numberB;

  break;

 case 4:

  result = numberA/numberB;

  break;    

 default:

  std::cout<<"Incorrect option\n";

 }

//Show result

std::cout<<"Result is:"<<result<<::std::endl;

return 0;

}

a file named loan.html, write an HTML document that looks similar to figure 9-7 in the textbook. Write four functions with these headers:
function doPayment ( )
function doBalance ( )
function computePayment (principal, annualRate, years, periodsPerYear)
function computeBalance (principal, annualRate, years, periodsPerYear, numberOfPaymentPaidToDate)
The first two functions (doPayment and doBalance) do the following:

Take no parameters.
Are called from an onclick attribute.
Get input from the user.
Call the computePayment or the computeBalance function.
Display a result to the user.
The computePayment function computes and returns the monthly payment for a loan with a fixed annual interest rate. The formula for computing a loan payment is

p = ar
1 − (1 + r)−n
Where p is the payment per period, a is the loan amount, r is the interest rate per period, and n is the total number of periods throughout the life of the loan.

The computeBalance function computes and returns the balance for a loan with a fixed annual interest rate. The formula for computing the balance of a loan after d payments have been made is

b = a (1 + r)d − p ( (1 + r)d − 1 )
r
Where b is the balance or payoff amount, a is the loan amount, r is the interest rate per period, p is the payment per period, and d is the number of payments paid to date.

Answers

Answer:

function computePayment(principal, annualRate, periodsPerYear){

   var pay;

   pay = (principal * annualRate)/(1-(1+annualRate)-periodsPerYear);

   return pay;

}

function computeBalance(principal, annualRate, periodsPerYear, numberOfPaymentsPaidToDate){

   var balance ;

   let num = (principal*(1+annualRate)*periodsPerYear);

   let denum = numberOfPaymentsPaidToDate *((1+annualRate) * periodsPerYear-1)*annualRate;

   balance = num-denum;

   return balance;

}

function doPayment(){

   let loanAmount = document.getElementById("principal").value;

   let rate = document.getElementById("rate").value;

   let duration = document.getElementsById("time").value;

   let result = computePayment(loanAmount, rate, duration);

   document.getElementsById("periodPay").value = result;

}

function doBalance(){

   let loanAmount = document.getElementById("principal").value;

   let rate = document.getElementById("rate").value;

   let duration = document.getElementById("time").value;

   let currentPaid = document.getElementById("paidMonths").value;

   let result = computeBalance(loanAmount, rate, duration, currentPaid);

   document.getElementById("displayBalance").value = result;

}

Explanation:

The javascript source code defines four functions. The 'doPayment' and 'doBalance' functions are initiated with the onclick properties of the HTML file buttons of the loan calculator. The doPayment function gets the user input from the HTML file and assigns them to variable which are used as the parameters of the computePayment function called.

The doBalance function also retrieve user input from the HTML file and calls the computeBalance function to calculate and return the balance of the loan to be paid.

write a program to prompt for a score between 0.0 and 1.0. If the score is
out of range, print an error. If the score is between 0.0 and 1.0, print a grade
usmg the following table:
Score Grade
0.9 A
08 B
07
= 0.6 0
0.6
if the user enters a value out of range, print a suitable error message and exit.
For the test enter a score of 0.85.
Check Code
Reset Code​

Answers

score = float(input("Enter Score: "))

message = "Score out of range"

if score >= 0.9:

   message = "A"

elif score >= 0.8:

   message = "B"

elif score >= 0.7:

   message = "C"

elif score >= 0.6:

   message = "D"

elif score < 0.6:

   message = "F"

else:

   message = "Out of Range"

print(message)

I hope this helps!

If anyone has the answer for this that would be really helpful!!

Answers

Hope this will help you...

Answer:

1.a

2.f

3.b

4.c

5.e

6.g

7.h

8.d

Explanation:

what is collaboration

Answers

Answer:

the action of working with someone to produce or create something.

Collaboration is the process of two or more people, entities or organizations working together to complete a task or achieve a goal. Collaboration is similar to cooperation. Most collaboration requires leadership, although the form of leadership can be social within a decentralized and egalitarian group.

"True or False? Software designers use layering and other techniques to organize large software systems."

Answers

Answer:

True.

Explanation:

Software design can be defined as the process in which a designer or software developer uses a set of tools, techniques and components to create a graphical representation of a software that is intended to be used for solving a problem for the end users.

Hence, software designers use layering such as presentation, business, database, persistence layers and other techniques to organize large software systems.

Originally, Java was used to create similar apps as what other language?
Perl

Python

CSS

Javascript

Answers

the answer would be python. the first was javascript and they changed to python.

What is the main purpose of the status report? O A. To ensure that management and the team has a clear picture of the state of the project. B. To alert management to exceptional or unusual situations, C. To document the impact of change requests from the client. D. To detail the mistakes made in planning and budgeting,​

Answers

Answer:

A. To ensure that management and the team has a clear picture of the state of the project

Explanation:

hope this helps!

Answer:

A

Explanation:

Imagine you have a friend who is new to computing. He is not necessarily interested in going into programming, but he would like to know the basics in terms of how computers work, how programs are written, and how computers communicate with each other. You are talking to him about the basics, but he keeps confusing operating systems, programming language, computer language, and markup language. How would you use very plain language to explain to him the differences between these things and how they interact with each other?

Answers

An operating system is responsible for the overall function of a computer system and it enables us to program a computer through thes use of a computer language.

What is programming?

Programming can be defined as a process through which software developer and computer programmers write a set of instructions (codes) that instructs a software on how to perform a specific task on a computer system.

What is an operating system?

An operating system can be defined as a system software that is pre-installed on a computing device, so as to manage computer hardware, random access memory (RAM), software, and all user processes.

Basically, an operating system is responsible for the overall function of a computer system and as such without it, a computer cannot be used for programming. Also, a computer language is typically used for programming while a markup language is a type of computer language that is mainly used for designing websites through the use of tags.

Read more on software here: https://brainly.com/question/26324021

what does libtard mean

Answers

Answer:

Normally, It is a person of the opposite political belief that thinks that liberals/leftists are stupid for what they say. Most of the time, this "insult" is mostly used by Right-Winged Conservitives or used as a joke by leftists to show how funny it is when conservitives say it.

Answer:

it means a liberal r3tard. lib-tard

Explanation:

Which task can be completed with the Template Organizer?
A. grouping templates based on categories
B. adding styles from one template to another
C. listing template names in ascending order
D. defining the numbering properties of templates

Answers

Answer:

B is the answer

Explanation:

i just got it right

Answer:

b thats the answer bby <3

Explanation:

4.5 code need help we are not to the stage .format Teacher does not want that

Answers

i = 0

while True:

   word = input("Please enter the next word: ")

   if word == "STOP":

       break

   i += 1

   print("#"+str(i)+": You entered "+word)

print("All done. "+str(i)+" words entered.")

I hope this helps!

Other Questions
Please answer as fast as possible Change the speech from direct to indirect. Mom, please dont be angry with me. It was an accident. If 3g - 11 + 3y, what is the value of y when g is 12? I need help!! Art labeling- ovarian cycle A line intersects the y-axis of the point (a, b) Is a = 0? Is b = 0? Explain. Guys if you see this please help me All of the following have specific grant opportunities based on personal traitsexceptO A. disabled studentsO B. female studentsO C. children of politiciansO D. American Indian studentsPlease help!! Why is it Called Eleven and Not Onety-One? This is an actual question I'm curious.Same goes for Twelve. Onety-Two? 13? Onety-Three? PLEASE HELP Fill in the blanks with the correct word or words.8. Ce sont____________cahiers? (Use the plural form of "your.")9. Oui, ce sont____________cahiers. (Use "our.")10. Le prof est paresseux. La prof est__________. (Use the feminine form of paresseux.)Fill in the blanks in the following dialogues with the appropriate statement or question.11. Elle est gentille la prof de biologie?Non,_________. (Use the opposite adjective.)12.__________? (Use inversion.)-Non, il n'y a pas de papier sur le pupitre.13.___________? (Use Est-ce que.)-Non, il n'y a pas de feutre.Answer:Your search 4. (08.01, 08.02, 08.03 HC)Create a factorable polynomial with a GCF of 5z. Rewrite that polynomial in two other equivalent forms. Explain how each form was created. (10 points) d) Relato9.- Cuando el propsito de los anuncios espresentar informacin acerca de un beneficiopara las personas y tienen un fin social opoltico se denominan:a) Anuncios publicitarios.b) Propaganda.c) Anuncios culturales.d) Anuncios televisivos.Lalabas - tu jugar al tenis?A. conocesB. SabesC. SabeisD. Sabe A square table has a perimeter of 16 feet.Which of these is the length of a side ofthe table? need help please and thank you What are the two factors that affect the strength of the gravitational force between objects. Please include a definition or description of them :)) Attractions between particles hold the particles of liquids and solids close together.Why is the attraction that particles have for each other not enough to keep gasparticles close together? Time Warner Cable charges $30 per hour and a trip fee of $55 for each service call.Which of the following equations can be used to model this situation? Round off the measurement 0.002 015 5 m to three significant figures. Is the word teams in this sentence correct? ( its number 4