+ 1
How to print random numbers of any range be printed on same line not individually at new line using Python 3
5 Answers
+ 11
import random
print("here is a random number between 1 and 400:",random.randint(1,400))
+ 7
from random import randint
myrandoms = [randint(0,x) for x in range (20)]
print (myrandoms)
+ 3
@smaranjit show me that please
+ 1
@Oma Falk I wanted this type output, thanks....
I have tried to generate roll no of range(8) using def and magic method... successful though complicated one
0
import random
class Random:
def __init__(self,ran):
self.ran=ran
def __getitem__(self,index):
return self.ran[index+random.randint(-1,1)]
rand_om=Random(["0", "1"," 2", "3"," 4", "5"," 6", "7"," 8"])
a=rand_om[0]+rand_om[1]+rand_om[2]+rand_om[3]+rand_om[4]+rand_om[5]+rand_om[6]+rand_om[7]+rand_om[8]
print("guess what your 9digit may be"+a)