jeudi 17 mars 2022

'random' is not call callable error message; unable to print the value when number3 is not > than number1 [closed]

Create program called reallyrandom.py that has a function that takes in three arguments and prints one integer.

  • Your random seed should be set to 42.
  • The first argument should correspond to the size of a np.randint - values from 0 to 10.
  • The second is an integer that you will multiply the randint by.
  • The third argument is a value you will index the result of the multiplication by.

You will print the integer that was indexed as ‘Your random value is x’ where x = the result of the indexing.

The program should not crash if the third value is larger than the first; it should not print anything to the screen.

Code

import sys
import numpy
import random

numpy.random.seed(42)

number1 = int(sys.argv[1])
number2 = int(sys.argv[2])
number3 = int(sys.argv[3])


def randomized(a, b, c):
    arg1 = numpy.random.randint(0, 10, size=a)
    arg2 = arg1 * b
    return arg2[c]


if number3 > number1:
    pass
else:
    random_value = random(number1, number2, number3)
    print(f"Your random value is {random_value}")

randomized(number1, number2, number3)

Test Case Examples:

python3 reallyrandom.py 1 2 9 
python3 reallyrandom.py 44 3 17
python3 reallyrandom.py 77 -3 55
python3 reallyrandom.py 2 4 10 

Expected Output:

Your random value is 21
Your random value is -9

Error Message

'random' is not callable



Aucun commentaire:

Enregistrer un commentaire