0

python group 2 numbers one through 12 with no repeats

i was asked to make a small program that would create 6 groups of two numbers from 1 to 12 with no repeating numbers I am struggling to even get started with this one any help would be amazing

25th Mar 2022, 7:51 PM
David Aseltine
David Aseltine - avatar
2 ответов
+ 2
This is a straightforward solution that I am visualizing: (1,2),(3,4),(5,6),(7,8),(9,10),(11,12) See that each group consists of (i,i+1). With that insight you can write pseudocode: Initialize i=1. Repeat while i<=12 print the group Increment i for the next group, i=i+2.
25th Mar 2022, 8:31 PM
Brian
Brian - avatar
+ 1
From random module: randInt( start, end) returns a number from start to end inclusive randrange( start, end, step_count) returns from the range random.sample( ) returns a unique item from sample.. Hope it helps..
25th Mar 2022, 8:15 PM
Jayakrishna 🇮🇳