Essay Analysis

 

 

 

1. Give examples of a properly indented if-else (or if-elif-else) structure and one that is not properly indented. (Hint: The one that is not properly indented shouldn’t run in IDLE.)

 

2. If you need to declare a list with no elements, how would you do that? Also, why would you ever need to do that?

 

3. Declare a list with several elements. Then create a for-loop that loops through every element and prints it on its own line.

 

4. What is the lower() method? What data type uses the lower() method? How does it help with user-friendliness?

 

5. How could you avoid a division-by-zero error by using an if-else statement?

 

6. How would you avoid a division-by-zero error by using a while loop?

 

7. What is the simplest, most straightforward way to (intentionally) construct an infinite loop?

 

8. What could you add to an otherwise infinite loop to make it so that it can break?

 

9. What is the difference between break and continue?

 

10. Create an example of a heterogeneous list and an example of a homogeneous list.

 

11. What is the difference between a list and a tuple? What is one reason you would use a tuple over a list?

 

12. How do you create a tuple? Name one operation you can do with an element of a list that you cannot do with an element of a tuple.

 

13. What does the word def create?

 

14. When would you use the condition if __name__ == ‘__main__’ in your program?

 

15. What does it mean to modularize your program, and why would you do it?

 

16. What function would you use in a for loop to make the loop execute an exact number of times (e.g., five times)?

 

17. What does the isdigit() function do and when would you use it?

 

18. What is the difference between = and ==? When would you have to use == instead of =?

 

19. What is the difference between an argument and a parameter? Please write some Python code to illustrate the difference.

 

20. Provide examples of data that would belong to each of the four different data types we learned about in this class: strings, integers, floating point numbers, and Boolean values

 

21. How would you convert data of numeric types to a string, or of the string type to the two numeric types using the functions we learned about in this class?

 

22. If a list, my_elements[], contains seven items, what value does len(my_elements) return? What is the index number of the first element? What is the index number of the last element?

 

23. What is an escape sequence? Please give an example of two that were used in the class.

 

24. Define syntax, runtime, and logical errors. Which one is likely to be a source of difficulty for a beginner in a particular language? Which one is trickier and will be a source of problems throughout your programming career?

 

25. The operators + and * can mean different things in Python, depending on the data types on each side. Please explain the different ways these operators work. Also explain under what circumstances the Python interpreter would encounter a runtime error.

 

26. In the context of programming logic and computer science, define algorithm.

 

 

 

 

 

 

 

This question has been answered.

Get Answer