GoConqr has a new look! Let us know what you think.

Mind map

#Q1: How does the random.randint(_,_) work?

Eric Chao Computer Science English

Map content

#Q1: How does the random.randint(_,_) work?

  1. #Q2: What is "random" and what is the purpose of using the period (.) before randint?

    • #Q3: What does the function print(_) do in the next line of code?
      • #Q4: What is the purpose of the (+) operator in the next line of code?
        • #Q5: What is the purpose of the function str(_) in the next line of code?
          • #Q6: Is this variable (largest) global or local? Why?
            • #Q7: What does None mean?
              • # Q8: What is inputValue? Why is it necessary for this function?
                • # Q9: What does return do?
                  • # Q10: What is the difference between declaring, defining, and calling a function?
                    • # Q11: How was the variable message built?
                      • The variable message was built by stating the desired results from the five random numbers. The general idea of each numbered result was to state what we were looking with a string and then calling the function that we defined above. Ultimately, the message variable was an extremely long string or text that is ultimately printed by the last line of code.
                    • Declaring a function tells the compiler the function name and how to call the function. Specific parameters need to be included when declaring the function.
                    • Defining a function is considered the body of the function. The programmer must include what the specific function needs to execute when it is called.
                    • Calling the function is simply having the function execute as part of the code. You will call the function by including specific parameters for the function to execute and then the body will execute and return an intended result.
                  • return ensures that an data type is returned after the function is called. When a function is called, it is typically expected that a function is performed and returns a desired result. In this Assignment, we return different values depending on the function that is called.
                • The inputValue is a parameter in this function that the user has input. It is necessary for this function because it is necessary to compare the inputted values to find the randomNumbers that are greater than the inputValue
              • None means that the variable is assigned to a null value or no value at all. Null is usually used when a value is not defined yet, such as the smallest variable.
            • The variable (largest) is a local variable because it is instantiated inside the function. It cannot be used anywhere else in the code except for in the function
          • The purpose of str() is to convert the return type of the randomNumber into a string so that when print() is called a string is printed out onto the screen.
        • The purpose of the (+) operator is to combine or add together a string of characters, so that it appears in one line on the screen.
      • The print(_) function will print out the string of characters inside the parenthesis onto the screen.
    • At the top of the code the random module was imported. Having random. before randint() calls the implemented random module to allow the program to randomly choose an integer between the two values
  2. The random.randint(_,_) chooses a random number between two given values.

Information

Description
Computer Science Mind Map on #Q1: How does the random.randint(_,_) work?, created by Eric Chao on 02/09/2021.
Created by
Eric Chao
Views
1
Rating

Feedback

What is it about?

What do you think of the new look?

How do you like it?