В стандартном модуле 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
🇧🇩#Bangladesh – Il National Citizen Party (#NCP), fondato dagli studenti Gen Z che hanno portato alla caduta dell’ex premier Sheikh #Hasina, si coalizzerà con i partiti islamisti in vista delle elezioni di febbraio. Diversi dirigenti e candidati riformisti si sono dimessi in seguito alla decisione che potrebbe portare il clero islamico al governo.
@UltimoraPolitics24
News: Former #Sudan PM Hamdok says Islamist factions major obstacle to ending war
Abdalla Hamdok, Former Sudanese Prime Minister and head of the Somoud civilian coalition, has said Islamist factions linked to Sudan’s former ruling party are among the main obstacles to ending the country’s nearly three-year civil war, according to a report by Abu Dhabi-based newspaper The National.
Speaking to the newspaper on the sidelines of the 39th African Union summit in #Addis_Abeba, Hamdok said Islamist groups and the National Congress Party (#NCP) — the political party of ousted president Omar Al Bashir — remains key actors resisting peace initiatives and efforts to reach a broader national consensus.
He also criticized Sudan’s army chief, Gen Abdel Fattah #Al_Burhan, for insisting on a military solution to defeat the rival Rapid Support Forces (#RSF). Al Burhan has publicly ruled out peace....
https://web.facebook.com/AddisstandardEng/posts/pfbid02qycixQfoRJLo5F9EWtxgsymfNbxMqUa9D4Qquz6X3DjfUBUFxig1b3xTGb3MzEHHl
🇧🇩#Bangladesh – Oggi oltre 120 milioni di cittadini sono stati chiamati alle urne per rinnovare i 350 seggi del Parlamento, le prime elezioni dopo la deposizione della premier Sheikh #Hasina e la messa al bando della Lega Awami. Si sono sfidati il Partito Nazionalista Bengalese (#BNP) di Tarique #Rahman (rientrato dall’esilio a Londra dopo 17 anni), di centro-destra, per la liberalizzazione dell’economia, vicino alla classe media e all’esercito, e la coalizione guidata dal partito islamista Jamaat-e-Islami (#Jamaat) di Shafiqur #Rahman, che punta a introdurre la sharia nel Paese. La coalizione include il Partito Nazionale dei Cittadini (#NCP), fondato dai leader delle proteste studentesche, ma l’alleanza con gli islamisti è stata fortemente contestata da donne, laici e minoranza indù che avevano sostenuto le proteste. Risultati nelle prossime ore.
@UltimoraPolitics24