Ask Question
20 December, 07:40

Create the setStyles () function using the commands listed in the steps below. Christine wants one of five fancy style sheets to be randomly used when the page is opened. Declare the styleNum variable equal to the value returned by the randInt () function, using 5 as the parameter value.

+1
Answers (1)
  1. 20 December, 10:52
    0
    Hi there! This can be implemented in a simple Python function which uses the "random" module to generate the number.

    Explanation:

    Using Python as the languge, we can write a the below code in a file called styles. py. The first line imports the randint function from the "random" module. The setStyles () function declares an array or 5 elements (here I have just used numbers but these could be string names of the stylesheets as well). Next, styleNum is assigned the random number and the associated stylesheet is selected from the array of stylesheets.

    styles. py

    from random import randint

    def setStyles ():

    stylesheets = [1,2,3,4,5];

    styleNum = randint (1,5);

    stylesheet = stylesheets[styleNum];

    print (stylesheet);

    setStyles ();
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Create the setStyles () function using the commands listed in the steps below. Christine wants one of five fancy style sheets to be ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers