Mind map
Q1: How does the random.randint(_,_) work?
Map content
Q1: How does the random.randint(_,_) work?
Function
- block of code which only runs when it is called and processes arguments and yields data as a result
- Source: https://www.w3schools.com/python/python_functions.asp
- block of code which only runs when it is called and processes arguments and yields data as a result
random.
- Module
- Source: https://docs.python.org/3/library/random.html
- A file containing a set of functions you want to include in your application
- https://www.w3schools.com/python/python_modules.asp
- An algorithm will generate a pseudo-random float number within the range of [0.0, 1.0)
- The functions in the module use this random number algorithm for specific tasks
- Module
randint
- Produce a number N within the range of numbers defined by the argument (a,b) so that a <= N <= b
- Source: https://www.w3schools.com/python/module_random.asp
- Produce a number N within the range of numbers defined by the argument (a,b) so that a <= N <= b
(_,_)
- argument
- information passed into a function
- the range of integers from where numbers are randomly generated
- argument
will generate a number that lies within the range of integers specified in the function's argument. This value is assigned to its corresponding variable
Assignment 1
- Q2: What is "random" and what is the purpose of using the period (.) before randint?
- The use of a period denotes the specific function being used from the list of functions in the module
- Function used
- The use of a period denotes the specific function being used from the list of functions in the module
- Q3: What does the function print(_) do in the next line of code?
- It will print the object defined by the argument by displaying it on the computer's output device
- Will display the following: "The numbers generated are: randomNumberA, randomNumberB, randomNumberC, randomNumberD, randomNumberE"
- Q4: What is the purpose of the (+) operator in the next line of code?
- The + operator combines two different strings
- https://www.w3schools.com/python/python_strings_concatenate.asp
- The + operator combines two different strings
- Q5: What is the purpose of the function str(_) in the next line of code?
- Converts defined object into its string version
- https://www.w3schools.com/python/ref_func_str.asp
- Converts defined object into its string version
- Q6: Is this variable (largest) global or local? Why?
- The variable is local because it is defined within the scope of the function
- https://www.w3schools.com/python/python_variables_global.asp
- Can only be used inside the function
- The variable is local because it is defined within the scope of the function
- Q7: What does None mean?
- None assigns a null value to a variable
- Q8: What is inputValue? Why is it necessary for this function?
- inputValue is a parameter for the countGreaterEqualNumbers function
- Denotes the number of arguments the function should expect
- A parameter is a variable listed inside the parentheses in the function definition
- inputValue is a parameter for the countGreaterEqualNumbers function
- Q9: What does return do?
- It is a command that has the function send an object (the return value) back to the script
- Q10: What is the difference between declaring, defining, and calling a function?
- Declaring
- Creating a function using the def keyword
- Defining
- Assigning a name to a declared function
- Calling
- Commanding script to run the function
- Declaring
- Q11: How was the variable message built?
- With the use of an if statement
- Condition is whether function4 has a null value
- , which indicates whether any of the random variables are odd numbers
- Conditional statements are either printing the odd numbers from function4 or stating that there are no odd numbers
- Condition is whether function4 has a null value
- With the use of an if statement
- 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 Valeria Niebles on 19/01/2021.
- Created by
- Valeria Niebles
- Views
- 0
- Rating