В стандартном модуле 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
During the 09 years period (2018-2026) for Delhi, the month of April witnessed its lowest monthly average AQI of 178 in the current year 2026 (barring 2020 - the year of lockdown due to Covid): Commission for Air Quality Management
#Environment
- 60-metre garbage mountain in Okhla is just 20 m now
- Recycled landfill waste is used for massive Eco park
- "Trees" have been planted too
#Environment
Tata Steel pilots HIsarna tech with ~50% lower capex and ~50% CO₂ reduction. 1 MTPA demo plant planned at Jamshedpur with ₹4,000 cr capex vs ₹9,000 cr blast furnace baseline. CO₂ cut up to 80% with CCS; commercialization targeted ~2030. #Environment
https://t.co/fc7NwWIvTP
An unprecedented weather event was witnessed in Jammu, where a tornado struck the area for nearly 10 minutes in Akhnoor. No damage to life or property has been reported. This marks the first recorded instance of a tornado in the region’s weather history. #Environment
India just turned plastic waste into a massive business opportunity. This policy is not about recycling, it’s about building the next manufacturing wave. #Environment
Discord @smileswe Midjourney #environment Francis henri de roche, julieta london, in the style of detailed fantasy art, imaginative prison scenes, dark blue and gold, trompe - l'œil illusionistic detail, intricate cityscapes, rustic renaissance realism
subscribe • free midjourney
Discord @Nikruz Midjourney #environment Map of fantasy land, two main buildings, one castle and one house, 2 big chests full of gold, graphiti style, vibrant colors, birds eye view, colourful
subscribe • free midjourney