CodeSolved

Solved Programming Questions & Exercises

To move the value of 2 variables

Practice Easy 18/ Download 2773 Views

Write a program that receives 2 numeric value from the input and stores in variables A and B. Then move the values of these two variables (the value of variable A is to be stored within B and the value of variable B is saved within a)

16 Answers

This answer is only visible to premium members
This answer is only visible to premium members
This answer is only visible to premium members
let msg = 'error'
alert(msg) 
This answer is only visible to premium members
This answer is only visible to premium members

This answer is only visible to premium members

Subscription is currently unavailable.
This answer is only visible to premium members
This answer is only visible to premium members
This answer is only visible to premium members
let msg = 'error'
alert(msg) 
This answer is only visible to premium members
This answer is only visible to premium members

This answer is only visible to premium members

Subscription is currently unavailable.
This answer is only visible to premium members
This answer is only visible to premium members
This answer is only visible to premium members
let msg = 'error'
alert(msg) 
This answer is only visible to premium members
This answer is only visible to premium members

This answer is only visible to premium members

Subscription is currently unavailable.
def swapvar (a, b):
    return b, a

first_num = int(input("please first num: "))
secend_num = int(input("please secend num: "))
first_num, secend_num =swapvar (first_num, secend_num)
print(f"\nthis is swaped first num: {first_num}\nand this is swaped secend num: {secend_num}\n")
Mhghasri Download Python
a=float(input("please,enter namber1:\n"))
b=float(input("please,enter namber2:\n"))
o=a
a=b
b=o
print("number1: ",a)
print("number2: ",b)

Zaras Download Python
a = int(input('a: '))
b = int(input('b: '))
a,b = b,a
print('...........')
print('a: ',a)
print('b: ',b)
Roham Download Python
a = []
b = []

num1 = int(input("1.Enter a number: "))
num2 = int(input("2.Enter a number: "))

a.append(num1)
b.append(num2)

print("a =",a ,"b =",b)

a , b = b , a
print("a =",a ,"b =",b)

User 3382 Download Python
a=int(input("enter a first number>>>"))
b=int(input("enter a second number>>>"))
print("a=" , a , "&" ,"b=" , b , "before to move thise numbers ")
temp=a
a=b
b=temp
print("a= ",a ,"b= ",b ,"after to move this numbers")
Shina Download Python
a = int(input("please enter a number: "))
b = int(input("please enter a number: "))
print("a = ", a ,"/", "b = ", b)
a, b = b, a
print("a = ", a ,"/", "b = ", b)

It was very good and one point I got in the quadruple line that A, B "simultaneously" was used and it wouldn't be the case. User 35


Hi good time. Thank you. I am glad to help you. Alirezamoghaddam


# Get two numeric values from the user
a = int(input("لطفاً مقدار عددی اول را وارد کنید: "))
b = int(input("لطفاً مقدار عددی دوم را وارد کنید: "))
# The displacement of values A and b
a, b = b, a
# Displays
print("پس از جابه‌جایی:")
print("مقدار a:", a)
print("مقدار b:", b)
Milad.bio Download Python
<< Previous page 1 2 Next page >>

Submit answer

Submitting answers is currently unavailable.

×
×
Close