#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2013
    Posts
    11
    Rep Power
    0

    Help with Python Program


    Hi everyone I am new to python, programing and computers in general. I need help writing the following in python code.

    Assume the following:
    a. Disk spooling is NOT being used.
    b. The printer does NOT have a hardware buffer to hold the output while the printer is printing
    (The theme music from Mission Impossible is playing faintly in the background).
    SIMULATE the following scenario
    A hypothetical program computes for three seconds then outputs a variable length record to be printed. The printer takes from 0.75 to 4.75 seconds (average time is 2.75 seconds) to print each output record. (Use a random number generator)
    The hypothetical program loops 500 times for each case of software buffers (0, 1, 2, 3, 4, 5, 10, 25, and 100 software output buffers). Calculate the AVERAGE time for the program to “virtually compute and print” a record from the 500 records, for EACH of the 9 choices of buffer. Plot the results (by hand is OK). The Y axis is from zero to 8 seconds, and the X axis is nonlinear and displays all nine cases of buffers.


    Thank you for your time, John
  2. #2
  3. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    Woodland Hills, Los Angeles County, California, USA
    Posts
    9,595
    Rep Power
    4207
    Question has been asked before many times around the web (including here):
    http://forums.devshed.com/php-develo...ed-885910.html

    Quick question, is this a univ. course question or is it on a website somewhere?
    Up the Irons
    What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
    "Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
    Down with Sharon Osbourne

    "I wouldn't hire a butcher to fix my car. I also wouldn't hire a marketing firm to build my website." - Nilpo
  4. #3
  5. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,709
    Rep Power
    480
    What is the use of a printer with no output buffer? Isn't a printer supposed to primarily put ink on a page? Or, these days, to make a gun? The printer sounds grossly defective.
    [code]Code tags[/code] are essential for python code and Makefiles!
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2013
    Posts
    11
    Rep Power
    0
    It is a question for a university operating system class. I can figure out how to write the code I just have no idea on how to structure the program. I have taken a beginner python course and nothing more so I am kinda lost on how the structure of the program would look. Also it is a simulation so that is throwing me off also. Thank you for any help you can provide.

    John
  8. #5
  9. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2013
    Location
    Saint-Petersburg, Russia
    Posts
    236
    Rep Power
    28
    I can figure out how to write the code I just have no idea on how to structure the program.
    If you "can figure out how to write the code" then you'd better start and show the people what is your progress. They you probably can get some help.

    Python programs do not need much "structure" at least for beginners. You need not care of putting your code into package, class and method like in Java. So you'd better start.

    Here is the tutorial:
    http://docs.python.org/3.3/tutorial/
  10. #6
  11. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,709
    Rep Power
    480
    It seems to me that the question is well beyond the level of "first or second program you ever wrote". If that helps. Did you skip a prerequisite class John_in_Parrish?
    [code]Code tags[/code] are essential for python code and Makefiles!
  12. #7
  13. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2013
    Posts
    11
    Rep Power
    0
    No I was not able to skip any pre-req's, It is not a programing course it is a operating systems course. I am at sophmore-junior level in system admin course. I really have no idea on where to start on this figuring out what it is asking. Sorry for the ignorance not looking for answers just trying to understand what it is that I am supposed to do and then turn that into python program. Sorry if I offended any of you. The professor is not very helpful in his explanation and tells us to surf the net as our resources. All online class with no office hours.

    I understand that with 0 buffers that the print time will be close to anywhere between 3-8 seconds depending on what random number is generated.

    The reason for the Random number generator to run 500 times is to give it a good avg.

    I understand that the more buffers you have will decrease the computer waiting to que up the next job

    I dont understand how to structure anything after that.



    #Lab 1 using python.
    Import random #Importing random number generator.
    def main():
    buffers= [0,1,2,3,4,5,10,25,100]; #Defining the buffers using list.
    for buffer in buffers:
    sum=0;

    for i in range (1, 500): # Create a loop which will create random number and increment 500 times.
    time= (random.uniform (0.75,4.75))+3
    sum = sum + time

    average= sum/500; #Finding the average of each buffers random numbers.

    print("For Buffer",buffer,",the average time is",average,"."); #Print the output.

    This is what I have been able to come up with and I cannot get it to run. I know I am way off. Thank you again for your help,

    John
  14. #8
  15. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,709
    Rep Power
    480
    I don't understand the question.
    [code]Code tags[/code] are essential for python code and Makefiles!
  16. #9
  17. Commie Mutant Traitor
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Jun 2004
    Location
    Norcross, GA (again)
    Posts
    1,804
    Rep Power
    1569
    EDIT: Looking back through the thread, I see that the OP did in fact have a programming pre-req for this course. I hereby withdraw this rant, though I'll keep it here for the sake of anyone who read it initially.


    Originally Posted by John_in_Parrish
    No I was not able to skip any pre-req's, It is not a programing course it is a operating systems course. I am at sophmore-junior level in system admin course.
    A System Administration curriculum that doesn't have at least one freshman level programming requirement? That doesn't sound right. Scripting is far too important a part of system administration, even in the Windows world, to ignore the need for at least some kind of introductory programming course. Windows administration lives and dies on PowerShell and VBS scripting.

    If you are talking *nix admin, Python is one of the languages (along with Perl and Bash scripting) that would be essential to know, as there are a large number of commonly used scripts written in in it and you'd at the very least have to know how to read their error messages when they fail. I cannot imagine a *nix administrator who doesn't know at least a little Perl and C, and Python is almost as necessary these days.

    What university is this, so I can discourage others from going there?
    Last edited by Schol-R-LEA; November 1st, 2013 at 06:30 AM.
    Rev First Speaker Schol-R-LEA;2 JAM LCF ELF KoR KCO BiWM TGIF
    #define KINSEY (rand() % 7) λ Scheme is the Red Pill
    Scheme in ShortUnderstanding the C/C++ Preprocessor
    Taming PythonA Highly Opinionated Review of Programming Languages for the Novice, v1.1

    FOR SALE: One ShapeSystem 2300 CMD, extensively modified for human use. Includes s/w for anthro, transgender, sex-appeal enhance, & Gillian Anderson and Jason D. Poit clone forms. Some wear. $4500 obo. tverres@et.ins.gov
  18. #10
  19. Commie Mutant Traitor
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Jun 2004
    Location
    Norcross, GA (again)
    Posts
    1,804
    Rep Power
    1569
    OK, before we proceed, let's get the code into [HIGHLIGHT] tags so we can read it:

    Python Code:
    #Lab 1 using python.
    import random  #Importing random number generator.
    def main():
    	buffers= [0,1,2,3,4,5,10,25,100]; #Defining the buffers using list.
    	for buffer in buffers:
    		sum=0;
     
    		for i in range (1, 500): # Create a loop which will create random number and increment 500 times.
    			time= (random.uniform (0.75,4.75))+3
    			sum += time
     
    		average= sum/500; #Finding the average of each buffers random numbers.
     
    		print("For Buffer",buffer,",the average time is",average,"."); #Print the output.
    Last edited by Schol-R-LEA; November 1st, 2013 at 08:35 AM.
    Rev First Speaker Schol-R-LEA;2 JAM LCF ELF KoR KCO BiWM TGIF
    #define KINSEY (rand() % 7) λ Scheme is the Red Pill
    Scheme in ShortUnderstanding the C/C++ Preprocessor
    Taming PythonA Highly Opinionated Review of Programming Languages for the Novice, v1.1

    FOR SALE: One ShapeSystem 2300 CMD, extensively modified for human use. Includes s/w for anthro, transgender, sex-appeal enhance, & Gillian Anderson and Jason D. Poit clone forms. Some wear. $4500 obo. tverres@et.ins.gov

IMN logo majestic logo threadwatch logo seochat tools logo