Mapa mental
mentalMap
Contenido del mapa
mentalMap
Q1: How does the random.randint(_,_) work? A1: random.randint(_,_) works by calling the function randint in the random library. The randint function takes two arguments, an upper and lower bound, which are integers that indicate the range of random numbers that could be selected.
- Q2: What is "random" and what is the purpose of using the period (.) before randint? A2: "random" is the library that the function "randint" is retrieved from. The period indicates where the name of the library ends and where the name of the function begins
- Q3: What does the function print(_) do in the next line of code? A3: The print(_) function prints out a visual on the screen of what you tell it to print. Without a print function, your code would run, but no outputs would be readable on your screen.
- Q4: What is the purpose of the (+) operator in the next line of code? A4: The (+) concatenates, or combines, the strings on either side of it. As a result, many strings can be printed on a single line, using one print function.
- Q5: What is the purpose of the function str(_) in the next line of code? A5: str() converts the data type of whatever argument is given to it into a string. In this case str() is converting the randomly generated integers into strings so they can be printed along with text strings.
- Q6: Is this variable (largest) global or local? Why? A6: This variable is local because it is only defined within the function getLargestRandom(). Because it is local, if we ran print(largest), the print function would default to a globally defined value of largest, if there was one defined.
- Q7: What does None mean? A7: None means that the variable is assigned an empty memory slot, but does not have a value. It is a placeholder until reassigned.
- Q8: What is inputValue? Why is it necessary for this function? A8: inputValue is the necessary parameter that this function requires to run. If we do not define a number (inputValue) by which to compare the randomly generated numbers to, we have no way of using the function to retrieve the quantity of random numbers greater and equal than an input value.
- Q9: What does return do? A9: The return lets the function return a value. In this case, the function returns None.
- Q10: What is the difference between declaring, defining, and calling a function? A10: Declaring a function, provides the compiler the name of the function, the number and type of arguments it takes and its return type. Declaration does not allocate memory. Defining a function is used to allocate memory to a function. It is done using the keyword def. After it is defined, the function ican be called to run when the proper arguments are given
- Q11: How was the variable message built? A11: The message was built by creating a string called message. New lines were added sequentially, with the \n to tell the print statement to go to a new line. The variable message was printed using a conditional cascade. In this case, it tests whether function4 has a value. If function4 is None, then the last line of the printed message is "4) There are not odd numbers". If function4 is not None, the alternative message, is printed, with the value of function4 added to the end.
- Q10: What is the difference between declaring, defining, and calling a function? A10: Declaring a function, provides the compiler the name of the function, the number and type of arguments it takes and its return type. Declaration does not allocate memory. Defining a function is used to allocate memory to a function. It is done using the keyword def. After it is defined, the function ican be called to run when the proper arguments are given
- Q9: What does return do? A9: The return lets the function return a value. In this case, the function returns None.
- Q8: What is inputValue? Why is it necessary for this function? A8: inputValue is the necessary parameter that this function requires to run. If we do not define a number (inputValue) by which to compare the randomly generated numbers to, we have no way of using the function to retrieve the quantity of random numbers greater and equal than an input value.
- Q7: What does None mean? A7: None means that the variable is assigned an empty memory slot, but does not have a value. It is a placeholder until reassigned.
- Q6: Is this variable (largest) global or local? Why? A6: This variable is local because it is only defined within the function getLargestRandom(). Because it is local, if we ran print(largest), the print function would default to a globally defined value of largest, if there was one defined.
- Q5: What is the purpose of the function str(_) in the next line of code? A5: str() converts the data type of whatever argument is given to it into a string. In this case str() is converting the randomly generated integers into strings so they can be printed along with text strings.
- Q4: What is the purpose of the (+) operator in the next line of code? A4: The (+) concatenates, or combines, the strings on either side of it. As a result, many strings can be printed on a single line, using one print function.
- Q3: What does the function print(_) do in the next line of code? A3: The print(_) function prints out a visual on the screen of what you tell it to print. Without a print function, your code would run, but no outputs would be readable on your screen.
- Q2: What is "random" and what is the purpose of using the period (.) before randint? A2: "random" is the library that the function "randint" is retrieved from. The period indicates where the name of the library ends and where the name of the function begins
Información
- Descripción
- Mapa Mental sobre mentalMap, creado por Claire Layton el 15/01/2021.
- Creado por
- Claire Layton
- Visitas
- 4
- Valoración