В стандартном модуле random есть две очень похожие функции
random.randint()
random.randrange()
Обе возвращают случайное значение из указанного диапазона
>>> random.randint(10, 20)
12
>>> random.randrange(10, 20)
17
В чем же отличие?
Дело в том что у randrange() есть третий параметр step.
randint() действительно возвращает случайное число из указанного диапазона.
randrange() на первый взгляд делает тоже самое если передать также два параметра.
Но есть указать еще и step то наш диапазон усложняется, то есть в него попадёт не полный ряд значений.
Например, я хочу получить случайное значение из диапазона но только чётное число. Тогда достаточно сделать так:
>>> randrange(10, 20, 2)
16
Таким образом получается что randint это частный случай randrange без указания параметра step.
Еще одно важное отличие в том, что randint() включает в диапазон второе значение а randrange() нет. То есть выражение randrange(10, 20) никогда не вернёт 20, а randint(10, 20) вернёт.
#tricks#basic
😄Paint
➖➖➖➖➖➖
🔘 The noun paint refers to coloured liquid that makes things look nice. The verb has different meanings. It can mean to put paint on something with a brush.
🔜 I'm going to paint this wall yellow, and this one white.
🔜The table was painted green.
🔘 Paint can also mean to make a picture of something, using paint.
🔜 She painted a portrait of me, it looks great.
🔜 The artist painted the beautiful landscape.
🔘 Paint can also mean to apply a liquid (not just paint) to something with a brush.
🔜 Paint the pastry with egg before putting it in the oven.
🔜 Paint the wood preserver on the fence to protect it.
#Paint👨🏫@America
➖➖➖➖➖➖➖➖➖➖➖➖
🆕 Crypto News @Money
😁 Crypto Game @Egame
🇺🇸 US News @America
🇯🇵 Japan News @Japan
🇦🇪 UAE News @Dubai
▶️ Popular Movies @Videos
😜 Best Funny Video @Funnys
😄Paint
➖➖➖➖➖➖
🔘 The noun paint refers to coloured liquid that makes things look nice. The verb has different meanings. It can mean to put paint on something with a brush.
🔜 I'm going to paint this wall yellow, and this one white.
🔜The table was painted green.
🔘 Paint can also mean to make a picture of something, using paint.
🔜 She painted a portrait of me, it looks great.
🔜 The artist painted the beautiful landscape.
🔘 Paint can also mean to apply a liquid (not just paint) to something with a brush.
🔜 Paint the pastry with egg before putting it in the oven.
🔜 Paint the wood preserver on the fence to protect it.
#Paint👨🏫@America
➖➖➖➖➖➖➖➖➖➖➖➖
🆕 Crypto News @Money
😁 Crypto Game @Egame
🇺🇸 US News @America
🇯🇵 Japan News @Japan
🇦🇪 UAE News @Dubai
▶️ Popular Movies @Videos
😜 Best Funny Video @Funnys