On Saturday, 21 April 2012 18:35:26 UTC+1, someone  wrote:
> On Saturday, April 21, 2012 12:28:33 PM UTC-5, someone wrote:
> > Ok, this is my dillema, not only am I new to this programming buisness, 
> > before the last few days, I did not even know what python was, and besides 
> > opening up the internet or word documents, that is most of what I know. 
> > Yet, I have a professor who should be on Psych medication for giving us 3 
> > projects, 2 of which I have not listed here to do. I was able to do 
> > research over the last 3 days, and I have spent 3 days on this project, by 
> > borrowing others ideas on this project. Below, you will find my professors 
> > assignment (oh, and due in one week right before finals, so I am stressing 
> > out so much, cause I don't know why he is crazy enough to assign crap like 
> > this a week before finals when I have Calculus final,chem final, etc. I 
> > have figured out most of the assignment, and below, it will be posted after 
> > the teacher's post of the assignment. What I need help with, and I have 
> > tried relentlessly to find, is how to put freaking stars(asterisks) as 
> > border around a list without installing any other program to a portable 
> > python, of course, this is where my problem lies. Below, you will see what 
> > I have done, please, help!!!
> > You are required to complete and submit the following programming projects 
> > in Python by the indicated deadline:
> > 
> > Standard Header Information project (5 pts):
> > Write a program that will:
> > 1) Ask the user for the following information:
> >     - name of file to be created for storing SHI
> >     - user’s name (as part of SHI)
> >     - user’s course and section (as part of SHI)
> >     - user’s semester and year (as part of SHI)
> >     - user’s assignment title (as part of SHI)
> > 2) Write the above SHI data to a text (.txt) file with the name chosen by 
> > the user (above)
> > 3) Close the file that the SHI data was written to
> > 4) Open the file with the SHI data (again)
> > 5) Read the data into different (from part 1) variable names
> > 6) Display the SHI data read from the file in the interpreter with a border 
> > around the SHI data (include a buffer of 1 line/space between the border 
> > and SHI data). An example might look like:
> > 
> >     ***********************
> >     *                     *
> >     * First Name and Last *
> >     * ENGR 109-X          *
> >     * Fall 2999           *
> >     * Format Example      *
> >     *                     *
> >     ***********************
> > 
> > 
> > textfile=input('Hello, we are about to create a text file. An example would 
> > be: (sample.txt) without the parenthesis. What ever you do name it, it 
> > needs to end in (.txt). What would you like to name your textfile?')
> > userinput=[input('What is your name?'),input('What is your Course Section 
> > and Course number?'),input('What is the Semester and year?'),input('What is 
> > the title of this class assignment?')]
> > for item in userinput:
> >     openfile=open(textfile,'w');openfile.writelines("%s\n" % item for item 
> > in userinput);openfile.close()
> > x=textfile;indat=open(x,'r');SHI=indat.read()
> > def border(Sullivan):
> >     string=SHI
> >     stringlength=len(string)
> >     stringlength=stringlength("%s\n" % item for item in stringlength) + 2 * 
> > (3 + 3)
> >     hBorder=stringlength//2*"* "+"*"[:stringlength%2]
> >     spacer="*"+" "*(stringlength - 2)+"*"
> >     fancyText="*  "+string+"  *"
> >     return(hBorder,spacer,fancyText,hBorder)
> > 
> > textTuple = border(SHI)
> > for lines in textTuple:
> >     print (lines)
> 
> almost forgot, it has to have a 1 inch border around the top, bottom, left, 
> and right, with it being aligned to the left. In the picture above, that is 
> not how it actually looks, the stars to the right are aligned on the right, 
> not right next to each other. Thanks.

Honestly phrased question - well done.

Look at the textwrap module - I have no idea how you'll got an inch outputting 
in just text, as I might have a slightly different font setting and logical and 
physical inches are different.

Good luck, Jon.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to