CodeSolved

Solved Programming Questions & Exercises

To move the value of 2 variables

Practice Easy 18/ Download 2364 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)

14 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 = 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("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
var num1 = prompet("عدد a")
var num2 = prompet("عدد b")
var as = num1
var as2 = num2
num1 = as2
num2 = as
a = int(input("enter a number: "))
b = int(input("enter a number: "))

print("befor:")
print(f"a:{a}")
print(f"b:{b}")
a,b = b,a

print("after:")
print(f"a:{a}")
print(f"b:{b}")
User 195 Download Python
<< Previous page 1 2 Next page >>

Submit answer

Submitting answers is currently unavailable.

Related content

Detection using AI
×
×
Close