CodeSolved

Solved Programming Questions & Exercises

Generate random numbers to the desired number

Practice Easy 15/ Download 3433 Views Most popular

Write a program that receives the number of random numbers and its interval from the user and produces the number of random numbers.


Example:

Enter a number: 10
Enter min: 1
Enter max: 10
9
4
6
5
2
8
1
7
9
2

20 Answers

This answer is only visible to premium members
This answer is only visible to premium members
This answer is only visible to premium members
let msg = 'error'
alert(msg) 
This answer is only visible to premium members
This answer is only visible to premium members

This answer is only visible to premium members

Subscription is currently unavailable.
This answer is only visible to premium members
This answer is only visible to premium members
This answer is only visible to premium members
let msg = 'error'
alert(msg) 
This answer is only visible to premium members
This answer is only visible to premium members

This answer is only visible to premium members

Subscription is currently unavailable.
This answer is only visible to premium members
This answer is only visible to premium members
This answer is only visible to premium members
let msg = 'error'
alert(msg) 
This answer is only visible to premium members
This answer is only visible to premium members

This answer is only visible to premium members

Subscription is currently unavailable.
from random import *
doar = int(input('enter your number for doars : '))
az = int(input('enter your number that show where do you want do start : '))
payan= int(input('enter your number that show where do you want do end : '))
a = 0
while (doar):
    print(randrange(az , payan))
    a+= 1
    if a==doar:
        break
Zahra1392 Download Python
import random

def main():
    # Get the number of random numbers, minimum and maximum of the user
    count = int(input("Enter a number (count of random numbers): "))
    min_value = int(input("Enter min: "))
    max_value = int(input("Enter max: "))
    
    # The production and printing of random numbers
    for _ in range(count):
        random_number = random.randint(min_value, max_value)
        print(random_number)

# Implementation of the program
main()
Mma123 Download Python

You have to write a hard code you need to write more correctly. Samyar


import random
while True :
    min_number = input('Enter minimum number: ').strip()
    max_number = input('Enter maximum number: ').strip()
    if  min_number.lstrip('-').isdigit() and max_number.lstrip('-').isdigit() :
        min_number = int(min_number)
        max_number = int(max_number)
        if max_number <= min_number :
            print('Erorr...Enter the small number first, then the large one.')
            continue
        else :
            Number_of_random = input('Enter your desired number :').strip()
            if Number_of_random.isdigit():
                Number_of_random = int(Number_of_random)
                random_numbers = random.sample(range(min_number, max_number),Number_of_random)
            break
print(random_numbers)

Emrimo Download Python
import random
def randoming(x,y,z):
    my_list=[]
    count=0
    while 1:
        my_list.append(random.randint(x,y))
        count+=1
        if count==z:
            break
    return my_list
first_number=int(input("enter the first number>>>"))
last_number=int(input("enter the last number>>>"))
count_randoming=int(input("enter the count of randoming>>>"))
print(randoming(first_number,last_number,count_randoming))

Shina Download Python
import random
def randomnum(x, mi, m):
    for i in range(x):
        print(random.randint(mi,m))
number = int(input('enter a number: '))
min_num = int(input('enter min: '))
max_num = int(input('enter max: '))
randomnum(number, min_num, max_num)
import random
tedad=int(input('tedade adad haye random ra nam bebarid:'))
a=int(input('yek adad vared konid:'))
b=int(input('yek adad vared konid:'))
g=[random.randint(a,b) for i in range(tedad)]
print(g)
Maryam.n Download Python
import numpy as np
count = int(input("Enter a number: "))
min_value = int(input("Enter min: "))
max_value = int(input("Enter max: "))

random_numbers = np.random.randint(min_value, max_value + 1, count)

for num in random_numbers:
    print(num)
Roghaye.m Download Python
<< Previous page 1 2 Next page >>

Submit answer

Submitting answers is currently unavailable.

×
×
Close