Mapa mental
Global Variables
Contenido del mapa
Global Variables
1. How does the random.randint(_,_) work?
- random.randint(_,_) works by returning an random integer value that is between the two numbers within the parentheses.
- random.randint(2,10) will return a random number between and including 2 and 10.
- random.randint(_,_) works by returning an random integer value that is between the two numbers within the parentheses.
2. What is "random" and what is the purpose of using the period (.) before randint?
- "random" is a module that is built into python and has different methods to return random numbers. The period before randint is there to call the method within "random" to return a random integer.
- Other "random" methods that can be called using the period includes .randrange(_,__) which returns a random number between, but not including the numbers within the parentheses.
- "random" is a module that is built into python and has different methods to return random numbers. The period before randint is there to call the method within "random" to return a random integer.
3. What does the function print(_) do in the next line of code?
- print(_) displays the information within the parentheses in the output once the code is run.
- It will display something resembling: "The numbers generated are: 5 30 75 1700 -50".
- print(_) displays the information within the parentheses in the output once the code is run.
4. What is the purpose of the (+) operator in the next line of code?
- The (+) operator concatenates the strings it is between. Since the line of code is calling on global variables, the (+) operator has to be used to connect the string at the beginning of the print function to the subsequent variables.
5. What is the purpose of the function str(_) in the next line of code?
- The function str(_) in the next line of code is casting. It creates a string data type from an integer data type.
Functions, Declaration and Definition
- 6. Is the variable (largest) global or local? Why?
- The variable (largest) is local because the variable was created within a function.
- 7. What does None mean?
- None means there is no value or a null value.
- 8. What is inputValue? Why is it necessary for this function?
- inputValue is a parameter/argument. It is necessary for this function because the intended purpose of the function is to retrieve numbers based on a value that the user inputs.
- 9. What does return do?
- return "returns" the result of a function to the user. In this case, it shows return None which I believe is a placeholder for a variable.
- Function Calls
- 10. What is the difference between declaring, defining, and calling a function?
- Declaring a function is when you state what data type the function is. There are no declarations in python I believe. Defining a function is creating the function. Calling a function is actually executing the code within the function.
- 11. How was the variable message built?
- The variable message was built by updating the string stored in the variable. In each line, more strings are added on while still preserving the original message.
- 10. What is the difference between declaring, defining, and calling a function?
- 6. Is the variable (largest) global or local? Why?
Información
- Descripción
- Mapa Mental sobre Global Variables, creado por Alyssa M. el 14/01/2021.
- Creado por
- Alyssa M.
- Visitas
- 0
- Historial
-
- Creado por Alyssa M. · 14 ene 2021
- Copiado por Alyssa M. · 14 ene 2021
- Valoración