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
ASHA 777 [7]
3 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]3 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
An alarm clock draws 0.5 A of current when connected to a 120 volt circuit. Calculate its resistance.
mixas84 [53]

Answer:

120 vpm

Explanation:

8 0
3 years ago
Which view in file explorer can use to sort files by column heading
marusya05 [52]

It's details view. I hope this help.    

4 0
4 years ago
How do you respond to an email?
cupoosta [38]
It truely depends if you are using gmail.com yahoo.com outlook.com or any other email provider pls specify the email service that you are using and ill be glad to help .
5 0
3 years ago
Write the function setKthDigit(n, k, d) that takes three integers -- n, k, and d -- where n is a possibly-negative int, k is a n
liq [111]

Answer:

Explanation:

Let's do this in Python, first we need to convert the number into string in order to break it into a list of character, then we can replace the kth character with d. Finally we join all characters together, convert it to integer then output it

def setKthDigit(n, k, d):

n_string = str(n)

d_char = str(d)

n_char = [c for c in n_string]

n_char[k] = d_char

new_n_string = ''.join(n_char)

return int(new_n_string)

6 0
4 years ago
Which of the following is a benefit, as well as a risk, associated with peer-to-peer networks?
Anna71 [15]
<span>Clients depend on a working main server to perform their jobs: no, p2p relies on a structure without a central server. 

</span><span>Individuals can easily add or remove devices from their network: yes, this is true.

</span><span>Requires an IT professional, but easy to add clients to server and give privileges: no, in p2p, the server doesn't play a role.
</span>
<span>Software is maintained on the server, allowing for easy access to upgrade programs for all users: this is not an aspect of p2p</span>
5 0
4 years ago
Read 2 more answers
Other questions:
  • Spencer is a recent graduate who finds a dream car that costs $45,000. Even better, there's a 0% APR for 36 months offer from th
    13·1 answer
  • What do you think is the most effective way to ensure that code adheres to good coding standards? (1 correct answer)
    5·2 answers
  • What is "social
    13·2 answers
  • What does the memory controller prevent
    5·2 answers
  • Which of the following activities would be best-suited for a thinking mind map?
    10·2 answers
  • Write a method, including the method header, that will receive an array of integers and will return the average of all the integ
    7·1 answer
  • Which feature of REPL.it would you use to transmit your program to a friend?
    12·1 answer
  • Write a function isCString which accepts as arguments a const pointer to a char array and an integer for the size of the array
    12·1 answer
  • What was the strategy the company adopted for ERP implementation?
    6·1 answer
  • Which security protocol for wireless networks attempts to establish the same security for them as would be present in a wired ne
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!