We investigated another use for the Random application in our magic 8-ball program. We set up an array of string answers. Then we learned the operation of the while loop and the break statement.
Lesson 3 Operating Systems – We learned how the operating system manages memory to support the simultaneous running of multiple programs. Then we discovered how the operating system delegates time to hardware and user commands. We learned how file directories are structured and mapped to physical storage.
We examined the use of the append and extend commands in Python. We learned that these commands modify a list that is in place but do not return a new list. Then we learned how to use negative indexing in an array to access items from the end of the array. The need to access the last log entry or last user input is common when writing programs. Without the use of a negative index, you would have to calculate the end of an array making your program more verbose. We discovered that negative indexing is cleaner and easier making the Python code more readable and concise.
We explored the use of the various functions in the random module in Python. We discovered how to create unique random numbers without duplicates. We learned that Python uses zero-based indexing. We practiced accessing items in an integer array or list by using the indices of the location in the array. We learned how to set up lists with any beginning or ending and any step increment.
We learned how to generate a simple array of numbers in Python. Then we manipulated it to go in reverse, skip values, and start from a different number. We practiced using the list command with a range. We discovered that the built-in range function doesn’t support floating-point numbers, so you would have to use a different function from another library.
Lesson 3 Operating Systems – We learned about operating systems, their roles in managing computer resources, and how they facilitate interaction between hardware, software, and users. We have a better understanding of file systems and the importance of process management.
We began to work on assignment three. We wrote a program to guess a number received from a random number generator. This program requires the use of a random integer generator, a for loop with range, and an if, else-if, else for conditional statements.