Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Each of the following questions are worth 4 points. 1. What is the result of the

ID: 3600046 • Letter: E

Question

Each of the following questions are worth 4 points. 1. What is the result of the following calculation in Python's interactive mode? 7 112 2. Write the Python boolean literals. 3. Write a Python statement that evaluates to True if the variable whose name is num has a value greater than or equal to 0 and less than or equal to 10 4. When does a while loop stop? 5. What is the name of the Python function used to create a list of numbers in a for loop? 6. If the function mentioned above were run with the single argument 5, what is the list of numbers that would be created? 7. If the function mentioned above were run with the two arguments 1 and 5, what is the list of numbers that would be created 8. If the function mentioned above were run with the three arguments 1, 10 and 2, what is the list of numbers that would be created? 9. If the function above is run with only one argument, what does that argument specify? 10. What is the augmented assignment operator that multiples the value on it's right by the value of the variable on it's left and assigns that new value to the variable? 11. Write a function header for function named max that takes two integers as parameters 12. What do you call a variable that is defined inside a function?!f the variable is defined inside a function 13. If the variable is defined inside a function, can the code outside all functions use 14. What do you call a variable that is defined outside any function? 15. Where do parameters get their values? can another function use that variable?

Explanation / Answer

1. 7//2 would give the output of integer division of 7 and 2. that is 3
2. Boolean literals in python are True and False

3. var = (num>=0 and num<=10)

4. While loop stops when the condition specified in the while is not satisfied

5. range() function creates a list of numbers to loop through using for loop

6. range(5) will produce the list [0,1,2,3,4]

7. range(1,5) will give the list [1,2,3,4]

8. range(1,10,2) will give the list [1,3,5,7,9]

9. Argument specify the uppper bound (Exclusive) for the list, where as the lower bound is 0

10. *= is the operator. num*=10 will multiply num by 10 and store the result in the num

11. def max(a,b)

12. Variable defined inside a function in python is known as local variable, Unless it is explicitly declared using 'global' keyword, which makes in global. A local variable can be accessed from the function only.

13. When a variable is defined inside a function, no code outside the function can use that variable unless the variable is defined using the keyword global, which makes it global variable

14. Variables defined outside a function are known as global variables

15. parameters of a function get values , when we invoke them.
Whenever we invoke a function eg. sum(list), the passed value is assigned to the parameter and used in the method

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote