import random num = random.randint(1000, 9999) key = num % 1000 // 100 if key >= 5: new = num // 1000 * 1000 + 1000 else: new = num - num % 1000 print(f'Round off {num} at the position 100 is {new}.')