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

Write a Python script to display the header of any of your programs as below: #

ID: 3707222 • Letter: W

Question

Write a Python script to display the header of any of your programs as below:

# Semester: fall <2019>

# Topic: <Introduction to Python programming>

# Module: <main>.py

# Date: <02/02/2016>

# Author: <your name>

# Purpose of the module: <Display header information>

All data between < and > must be variables

Your script must provide for a variable number of “#” on top and bottom. Set it initially to 35

Be sure to include the line that invokes the interpreter

Explanation / Answer

Solution:

code:

#topic           : pyscript

#module          : main.py

#date            :20110930

#author          : bgw

#Purpose of the module   : purpose

###########################################################################

# Importing modules

from os.path import exists

#importing time

from time import strftime

#importing os module

import os

topic = raw_input("Enter a topic for your script: ")

# Removing spaces from topic.

topic = topic.replace(' ', '_')

# Checking wheteher file exists.

if exists(topic):

    print " Given name exists."

    exit(1)

module = raw_input("Enter a module:")

# Adding .py .

module = module + '.py'

# Setting the date.

date = strftime("%Y%m%d")

lname = raw_input("Enter author name: ")

ldescrpt = raw_input("Enter a Purpose of the module: ")

div = '###################################################################'

# file creation.

filename = open(topic, 'w')

# writing data.

filename.write(' #topic :' + topic)

filename.write(' #module :' + module)

filename.write(' #Purpose of the module :' + ldescrpt)

# Author name

filename.write(' #author :' + lname)

#Date

filename.write(' #date :' + date)

# getting divider sign

filename.write(' #' + div * 3 + ' ')

filename.write(' ')

# file closing after write.

filename.close()

# Clearing screen.

os.system("clear")

def leditor_lselect():

    '''To choose an editor.'''

    leditor = raw_input("Select a number: 1 for Emacs. 2 for Vim. ")

    if leditor == "1" or leditor == "2":

        if leditor == "1":

            os.system("emacs +12 " + topic)

            exit()

        elif leditor == "2":

            os.system("vim +12 " + topic)

            exit()

    else:

        os.system("clear")

        print "Sorry! wrong choice "

        print "Press <Ctrl + C> to quit. "

        return leditor_lselect()

leditor_lselect()

leditor_lselect()

I hope this helps if you find any problem. Please comment below. Don't forget to give a thumbs up if you liked it. :)

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