Ask Question
12 November, 23:37

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.

+4
Answers (1)
  1. 12 November, 23:54
    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?
Find 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 the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers