CSC111 Lab4 Solutions

From dftwiki3
Revision as of 15:59, 17 February 2010 by Thiebaut (talk | contribs) (Created page with '--~~~~ ---- <source lang="python"> import os def main1(): Id = raw_input( "Please enter Id of student (e.g. aa) " ) command = "111c-" + Id os.system( "lastlog -u…')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

--D. Thiebaut 20:59, 17 February 2010 (UTC)


import os
 
def main1():
     Id = raw_input( "Please enter Id of student (e.g. aa) " )
     command = "111c-" + Id
     os.system( "lastlog -u " + command )       
 
def main2():
    for Id in "abcdefghijklmnopqrstuvwxyz":
        user = "111c-a" + Id
        os.system( "lastlog -u " + user )

def main3():
     for semester in [ 'a', 'b' ]:
         for Id in "abcdefghijklmnopqrstuvwxyz":
              user = "111c-" + semester + Id
              os.system( "lastlog -u " + user )

def main4():
     for second in "abcdefghijklmnopqrstuvwxyz":
          for first in "abc":
               print first+second,  # comma to stay on the same line
          print # once we've printed 3, go to next line

def main5():
     filename = raw_input( "Filename? " )
     filenameNoExtension = filename[0:-3]
     print filenameNoExtension + "txt"


main5()