User Rating: 0 / 5

Star InactiveStar InactiveStar InactiveStar InactiveStar Inactive
 

If09. Given two variables of real type: A, B. Redistribute the values of these variables so that A is the smaller of the values, and B is the larger. Output new values of variables A and B.

Solution in Python 3:

import random

A = random.randrange(-3,3)
B = random.randrange(-3,3)

print("Number A:", A)
print("Number B:", B)

if A > B:
A,B = B,A

print("Number A:", A)
print("Number B:", B)