answer.
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
ASHA 777 [7]
2 years ago
5

Write a program whose input is two integers and whose output is the two integers swapped. Ex: If the input is: 3 8 the output is

: 8 3 Your program must define and call the following function. swap_values() returns the two values in swapped order. def swap_values(user_val1, user_val2)
Computers and Technology
1 answer:
Misha Larkins [42]2 years ago
4 0

Answer:

The program to this question can be given as:

Program:

def swap_values(user_val1, user_val2):  #define function

   return (user_val2, user_val1) #return values

if __name__ == '__main__': #define constructor.

   n1 = int(input('Enter first number :')) #input value form user

   n2 = int(input('Enter second number :')) #input value form user

   (n1,n2) = swap_values(n1,n2) #hold function values.

   print(n1) #print values

   print(n2) #print values

Output:

Enter first number :3

Enter second number :8

8

3

Explanation:

The explanation of the above python program can be given as:

  • In the python program we define a function that is "swap_values". This function takes two integer values that is "user_val1 and user_val2" as a parameters and returns variable values that is "user_val2 and user_val1".
  • Then we use a constructor in this we define two variable that is "n1 and n2" these variable are use to take user-input from the user and pass the value into the function.  
  • To hold the value of the function we use n1 and n2 variable and print these variable value.
You might be interested in
Given that a method receives three parameters a, b, c, of type double, write some code, to be included as part of the method, th
Debora [2.8K]

Answer and Explanation:

class Dis

{

public static void main(String args[])

{

Scanner sc=new Scanner(System.in);

System.out.println("Enter values for a,b,c");

double a=sc.nextDouble();

double b=sc.nextDouble();

double c=sc.nextDouble();

String s=discriminant(a,b,c);

System.out.println(s);

}

public String discriminant(double a, double b, double c)

{

double result;

result=(b^2-4ac);

if(result<0)

return "no real solutions"";

else return "";

}

}

Note:This program is written in JAVA

6 0
1 year ago
Read 2 more answers
1. What might you say to someone whose reason for investing in 90% bonds and 10% stocks is that they want a 6% return on investm
Gemiola [76]

Investing in 90% bonds and 10% stocks will provide an average return of 6% on investment.It is advisable to invest more portion in bonds  is safe and will give higher return for investment than stocks

Explanation:

1. According to the graph investing in 90% bonds and 10% stocks will provide an average return of 6% on investment.

2.Investing in bonds is safe than stocks ., because bonds bear fixed rate of interest ., and investing in the bonds having very less risk than the stocks. By comparing stocks and bonds with the help of graph ., it's very clear bonds has a positive growth starting minimum at 32.6% to maximum at 64.2% as returns .But stocks has a negative growth (value) from -8.2% to maximum -43.1% .,It is advisable to invest more portions in bonds is safe and better than invest in stocks.

5 0
2 years ago
An online article in 2001 described a study in which twelve sixth-grade students who had not previously played chess participate
ipn [44]
Bdbxhdhdhdbxbdhdhxhxhdhdhdhdhdhdhdhdhdbdhdhdhdhdhdhrhrhrhrhrhdhdhdhdisisieiejjdidieieieieieiei
6 0
2 years ago
The OSHA Workplace Poster 3165 is optional for workplaces.<br> A) True<br> B) False
bezimeni [28]

Hello, your answer is ready.


Answer: A) True



Best of luck!


~

Your pal papaguy

5 0
2 years ago
Read 2 more answers
If I execute the expression x &lt;- 4L in R, what is the class of the object `x' as determined by the `class()' function?
FinnZ [79.3K]

Answer:

integer

Explanation:

The expression can be implemented as follows:

x <- 4L

class(x)

Here x is the object. When this expression is executed in R, the class "integer" of object 'x' is determined by the class() function. R objects for example x in this example have a class attribute determines the names of the classes from which the object inherits. The output of the above expression is:

"integer"

Here function class prints the vector of names of class i.e. integer that x inherits from. In order to declare an integer, L suffix is appended to it. Basically integer is a subset of numeric. If L suffix is not appended then x<-4 gives the output "numeric". Integers in R are identified by the suffix L while all other numbers are of class numeric independent of their value.

7 0
2 years ago
Other questions:
  • Computer hardware without software is useless while computer software without hardware is meaningless. Discuss. Plz provide exam
    15·1 answer
  • In which of these places might you be most likely to find a peer-to-peer network? On the Internet In a hospital In a home In a l
    5·2 answers
  • An electronics store purchased a CD player at a wholesale price of $60 and then sold it at a 40 percent discount off the origina
    13·1 answer
  • Which type of word processing programs enables us to include illustrations within the program?
    6·1 answer
  • A company wants to publish Knowledge articles to its Customer Community. The articles should be organized for easy navigation by
    6·1 answer
  • A computer system uses passwords that are six characters and each character is one of the 26 letters (a-z) or 10 integers (0-9).
    13·1 answer
  • You are using a polynomial time 2-approximation algorithm to find a tour t for the metric traveling salesman problem. Which of t
    7·1 answer
  • After deploying a large number of wireless laptop computers on the network, Taylor, the IT director at Contoso, Ltd. decides to
    14·1 answer
  • Temperature Class Write a Temperature class that will hold a temperature in Fahrenheit and provide methods to get the temperatur
    6·1 answer
  • For a class project, Jerome builds a simple circuit with a battery and three light bulbs. On his way to school, Jerome drops his
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!