Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

354
Views
need random numbers in list using python code random.sample(range(1, 100), 3)

Can anyone tell me if this piece of code will produce only unique random numbers in a list :

random.sample(range(1, 100), 3) 
about 4 years ago · Santiago Trujillo
2 answers
Answer question

0

Yes sample is choosing unique numbers

Have a look here

about 4 years ago · Santiago Trujillo Report

0

random.sample(population, k)

Return a k length list of unique elements chosen from the population sequence. Used for random sampling without replacement.

To choose a sample from a range of integers, use an range() object as an argument

>>> import random
>>> print random.sample(range(1,100),3)
[77, 29, 45]
>>> 

https://docs.python.org/2/library/random.html#random.sample

about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!