Mind map
#Q1: How does the random.randint(_,_) work?
Map content
#Q1: How does the random.randint(_,_) work?
random.randint( , ) works through taking two integer parameters and randomly picking an integer between them.
- #Q2: What is "random" and what is the purpose of using the period (.) before randint?
- The "random" before the period refers to the imported library random. The period represents that a function will be called from the library random, and randint is the function being called from the library random.
- #Q3: What does the function print(_) do in the next line of code?
- print( ) will display the given variables when compiled.
- #Q4: What is the purpose of the (+) operator in the next line of code?
- When using the + operator within the print( ) function, this will combine the contents of the variables. If varA = "The " and varB is "cat" then when added in a print( ) function, the displayed result will be "The cat".
- #Q5: What is the purpose of the function str(_) in the next line of code?
- The function str( ) in that line of code will convert the values of the randomNumber variables, which are integers, into string data types.
- #Q6: Is this variable (largest) global or local? Why?
- Largest is a local variable due to it being defined within a function.
- #Q7: What does None mean?
- If a variable is defined as none, it basically creates an empty variable. This means that it is storing no value.
- # Q8: What is inputValue? Why is it necessary for this function?
- inputValue is an integer value that will be used to compare which random values are greater or equal to it. It is necessary to this function because without it, there will be no value to compare against.
- # Q9: What does return do?
- return is used within functions when a desired value needs to be outputted after the function has been ran.
- # Q10: What is the difference between declaring, defining, and calling a function?
- Declaring a function is stating that it is there, seen through using the "def" function, followed by the name of the function and the parameters it will use. Defining a function is done within the body of the function, giving the function its instructions and what it needs to return. Calling a function is using it within the main body of the program after the previous two steps have been done.
- # Q11: How was the variable message built?
- The variable message is built through continuously adding strings to the variable, containing different lines of information, followed by "\n". This creates a line break between the information so it is easy to read when printed.
- # Q11: How was the variable message built?
- Declaring a function is stating that it is there, seen through using the "def" function, followed by the name of the function and the parameters it will use. Defining a function is done within the body of the function, giving the function its instructions and what it needs to return. Calling a function is using it within the main body of the program after the previous two steps have been done.
- # Q10: What is the difference between declaring, defining, and calling a function?
- return is used within functions when a desired value needs to be outputted after the function has been ran.
- # Q9: What does return do?
- inputValue is an integer value that will be used to compare which random values are greater or equal to it. It is necessary to this function because without it, there will be no value to compare against.
- # Q8: What is inputValue? Why is it necessary for this function?
- If a variable is defined as none, it basically creates an empty variable. This means that it is storing no value.
- #Q7: What does None mean?
- Largest is a local variable due to it being defined within a function.
- #Q6: Is this variable (largest) global or local? Why?
- The function str( ) in that line of code will convert the values of the randomNumber variables, which are integers, into string data types.
- #Q5: What is the purpose of the function str(_) in the next line of code?
- When using the + operator within the print( ) function, this will combine the contents of the variables. If varA = "The " and varB is "cat" then when added in a print( ) function, the displayed result will be "The cat".
- #Q4: What is the purpose of the (+) operator in the next line of code?
- print( ) will display the given variables when compiled.
- #Q3: What does the function print(_) do in the next line of code?
- The "random" before the period refers to the imported library random. The period represents that a function will be called from the library random, and randint is the function being called from the library random.
- #Q2: What is "random" and what is the purpose of using the period (.) before randint?
Information
- Description
- Mind Map on #Q1: How does the random.randint(_,_) work?, created by Anthony Baldino on 17/01/2021.
- Created by
- Anthony Baldino
- Views
- 0
- Rating