Ask Question
16 July, 17: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. 16 July, 20:26
    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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers