Mapa mental
Assignment #1
Contenido del mapa
Assignment #1
RANDOM
- Q1: How does the random.randint(_,_) work? random.randint(a,b) will randomly select a value between 'a' and 'b' and assign it to the variable being defined.
- Q2: What is "random" and what is the purpose of using the period (.) before randint? random is a Python library and the period before randint indicates to the IDE that 'randint' is a function located in random.
PRINT
- Q3: What does the function print(_) do in the next line of code? The print() function prints out the text 'The numbers generated are:' and then uses casting to change the data type of the variables to strings, thus allowing them to be printed, and inserts spaces between the printed variables with the notation '+" "+'.
- Q4: What is the purpose of the (+) operator in the next line of code? The (+) operator attaches together the different pieces of text that are to be printed and in necessary in this case because the variables must be casted to strings.
- Q5: What is the purpose of the function str(_) in the next line of code? The function str() casts the variables to strings, which ensures that the print() function can print them out in the console.
- Q11: How was the variable message built? The variable message was built by calling the five functions created in this program and assigning them to five variables named 'function#'. The message then converts the output of these variables into strings and uses the (+) operator to attach them to other strings that describe them. The (/n) notation indicates a new line after each result. The message is updated by reassigning the variable to itself plus a new line of strings for each result. The message is also sent through an if-statement to determine which strings to add to the message depending on the result outputted by function4. Finally, the message is printed.
FUNCTIONS
- Q6: Is this variable (largest) global or local? Why? The 'largest' variable is local because it is located within a function.
- Q9: What does return do? The return statement indicates to the function to exit and stop looping, if applicable. It may also tell the function what value to return to the caller after exiting.
- Q10: What is the difference between declaring, defining, and calling a function? You declare a function when you create it with 'def functionName()'. You define a function when you enter variables and operations to be performed on both local and global variables by the function. You call a function when you type 'functionName()" into the program, with any applicable parameters, telling the IDE to run the function.
INPUT
- Q7: What does None mean? When None is assigned to a variable, it means that the variable has a null or nonexistent value.
- Q8: What is inputValue? Why is it necessary for this function? The inputValue is a parameter entered into the function when the function is called. It is necessary for this function because the function uses the inputValue to evaluate the function's output.
Información
- Descripción
- Mapa Mental sobre Assignment #1, creado por Catherine P el 14/01/2021.
- Creado por
- Catherine P
- Visitas
- 0
- Valoración