Answers for "how to generate a list of numbers in python"

3

create an array from 1 to n python

a_list = list(range(1, 5))

print(a_list)
[1,2,3,4,5]
Posted by: Guest on September-13-2020
2

creating list of numbers in python

# Python3 Program to Create list 
# with integers within given range 
  
def createList(r1, r2):
    return list(range(r1, r2+1))
      
# Driver Code
r1, r2 = -1, 1
print(createList(r1, r2))
Posted by: Guest on June-22-2021
0

python generate list of random numbers

import random
randomlist = []
for i in range(0,5):
n = random.randint(1,30)
randomlist.append(n)
print(randomlist)
Posted by: Guest on August-22-2020

Code answers related to "how to generate a list of numbers in python"

Python Answers by Framework

Browse Popular Code Answers by Language