Creating a Python Program for Assignment Header

Answered using GPT-4o mini by AI Answer Generator

Question:

When a program is run, there should be something at the top of the output which explains to the user what the program is all about, and something at the bottom that says it is finished. For every assignment you submit, when it runs the first thing that should be output is an assignment header that includes the date, your name, the name of the course and the name of the assignment. Create a program with just strings that prints an assignment header bordered on the top and bottom with a line of symbols (symbol is your choice). Use concatenation and repetition as described in section 2.4.2. After the bottom border include two lines of print() to make blank lines as a spacer before the next line of output. An assignment header might look something like this:


Tony Stark 10/19/24 Computer Information Systems Course 2110, Section 002 - Structured Problem Solving Assignment – Project #2 Coding in Python


Answer:

Certainly! Below is a Python program that prints an assignment header as you described. The program uses string concatenation and repetition to create the header and footer.

# Define the header information
name = "Tony Stark"
date = "10/19/24"
course_name = "Computer Information Systems"
course_details = "Course 2110, Section 002 - Structured Problem Solving"
assignment_title = "Assignment – Project #2 Coding in Python"

# Define the border symbol and length
border_symbol = "*"
border_length = 40  # Adjust the length as needed

# Create the border
border = border_symbol * border_length

# Print the assignment header
print(border)
print(name)
print(date)
print(course_name)
print(course_details)
print(assignment_title)
print(border)

# Spacer lines
print()  # Blank line
print()  # Blank line

# Indicate that the program is finished
print("Program finished.")

Explanation:

  1. Header Information: The program defines variables for the name, date, course name, course details, and assignment title.
  2. Border Creation: It creates a border using a specified symbol (*) and a defined length.
  3. Output: The program prints the border, followed by the header information, and then the border again.
  4. Spacer Lines: Two blank lines are printed for spacing.
  5. Completion Message: Finally, it prints a message indicating that the program has finished.

You can run this program in any Python environment, and it will display the formatted assignment header