Hi,
i have to draw int number from (1000, 9999) and create new number where I have to change units with tens and hundreds with thousands from the first number, Im new in python so it has to be done in the simplest way. I have something like this:
i have to draw int number from (1000, 9999) and create new number where I have to change units with tens and hundreds with thousands from the first number, Im new in python so it has to be done in the simplest way. I have something like this:
import random from typing import Final RANGE_MIN: Final[int] = 1000 RANGE_MAX: Final[int] = 9999 n = random.randint(RANGE_MIN, RANGE_MAX) print(f'{n = }') units = int((n // 10 ** 0) % 10) tens = (n // 10 ** 1) % 10 hundreds = (n // 10 ** 2) % 10 thousands = (n // 10 ** 3) % 10 print(f'{units = }\n{tens = }\n{hundreds = }\n{thousands = }')Now i dont know how to create the new number
Larz60+ write Oct-06-2022, 09:50 AM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Fixed for you this time. Please use BBCode tags on future posts.
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Fixed for you this time. Please use BBCode tags on future posts.