Week 8 Assignment: Lists And Arrays Instructions

Week 8 Assignment: Lists, Arrays Instructions: You will complete this Ass

Create a comment block with your name, course name, section, instructor name, week number, and date completed. Then, create an array containing the days of the week. Afterwards, use a loop to print each day. Save your code as a .py file and submit accordingly.

Paper For Above instruction

The assignment requires foundational Python programming skills, focusing on arrays (lists in Python) and loops. These skills are essential for developing programs that process and display collections of data. The task involves creating a list of the days of the week and then iterating through this list to print each day, demonstrating understanding of list creation and loop constructs in Python.

To begin, the programmer should start with a comment block containing personal and course information. This practice promotes professional coding standards and helps identify the code for assessment purposes. The comment block should include the student's name, course details, instructor's name, week number, and date of completion. Proper documentation is vital for clarity and academic integrity.

Next, the core of the assignment involves creating a list that contains the days of the week—typically starting from Monday through Sunday. The list in Python is a dynamic array structure, ideal for storing ordered data sets. For example: days_of_week = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"].

Python’s list syntax uses square brackets with comma-separated elements. This simple data structure enables efficient iteration and manipulation of the contained data. After defining the list, the student must implement a loop—preferably a for loop—to traverse the list and print each day in turn. This demonstrates understanding of iteration syntax in Python and how to access list elements.

Here is an example of how the code should be structured:

Comment Block:

Name: [Your Name]

Course: [Course Name]

Section: [Section]

Instructor: [Instructor Name]

Week: 8

Date Completed: [MM/DD/YYYY]

Create list of days of the week

days_of_week = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]

Loop to print each day

for day in days_of_week:

print(day)

This code achieves the goal of creating and printing the list content efficiently. The student should ensure proper indentation, syntax, and comments for clarity. Submitting this script as a .py file fulfills the assignment's requirements and demonstrates foundational Python skills.

References

  • Downey, A. (2015). Think Python: How to Think Like a Computer Scientist. O'Reilly Media.
  • Lutz, M. (2013). Learning Python (5th ed.). O'Reilly Media.
  • Murphy, E. (2017). Python Programming for Beginners. Packt Publishing.
  • Beazley, D., & Jones, B. (2013). Python Cookbook: Recipes for Mastering Python 3. O'Reilly Media.
  • Python Software Foundation. (2023). Python Documentation: Lists and Loops. https://docs.python.org/3/tutorial/datastructures.html