В стандартном модуле 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
Hobbs ripped as 'total disgrace' after vetoing bill limiting Chinese land ownership near military bases https://www.foxnews.com/politics/dem-governor-ripped-total-disgrace-after-vetoing-bill-limiting-chinese-land-ownership-near-military-bases#FoxNews
At least one dead after jet crashes into another plane at Scottsdale Airport in Arizona https://www.foxnews.com/us/least-one-dead-after-jet-crashes-another-plane-scottsdale-airport-arizona#FoxNews
🔻 Biden accused of ‘moving goalposts’ on percentage of Americans who need to get jab to return normal https://t.co/LzJxFI3CdG#FoxNews
September 29, 2021 at 04:45PM
via Twitter
@SenTedCruz
🔻 Border Patrol agents see 3,166% increase in convicted sex offender arrests in Del Rio Sector https://t.co/9X50ziXFYK#FoxNews
June 25, 2021 at 12:30AM
via Twitter
@SenTedCruz
#newtgingrich : RT @MariaBartiromo: Rep. Kevin McCarthy on debt ceiling talks: 'I will never give up' https://t.co/BRZg1fPCs7#FoxNews@SundayFutures@FoxBusiness
#newtgingrich : RT @MariaBartiromo: Trafalgar Group pollster Robert Cahaly predicts 'strong night' for Republicans https://t.co/Zttn6XkTOA#FoxNews@SundayFutures@FoxNews
#newtgingrich : RT @MariaBartiromo: Herschel Walker rips Warnock's lack of business experience: 'He never built anything' https://t.co/uprZBwsrTK#FoxNews@SundayFutures@FoxNews
#newtgingrich : RT @MariaBartiromo: Rep. Kevin McCarthy cites 'cost of living' as top priority for voters ahead of midterms https://t.co/0gukhkMjkr#FoxNews@SundayFutures@FoxNews
¿Lo de #RochaMoya es político? 🤔
🔴 La zar antidrogas de #EU reconoció en #FoxNews las acciones del gobierno de #Sheinbaum para combatir el narcotráfico 📺🇲🇽👏🏻
https://sinlineamx.com/eu-reconoce-eficiencia-gobierno-sheinbaum-combate-narco/