[Tutor] OK here goes nothing

glidedon glidedon <glidedon@c-zone.net>
Mon, 14 Jan 2002 19:06:42 +0000


Hi folks, this looks like the place for me.

I'm new to programming, new to Python and need tutoring :-) ( I also am an 
old dog trying to learn new tricks )

Anyway here's my first program, feel free to point out what I've done wrong 
or could do in a more "Pythonic" way.

Thanks for the effort !

Don

#!  /boot/home/config/bin/python

# Logbook 8 day recap

# this program will calculate hours on duty last 7 days, hours avalible 
tomorrow ,hours on duty last 8 days
# for a truck drivers log book

print
print " Enter Hours on duty"
print

# collect user input for first 8 days of record

day1 = input('Enter total hours on duty day1 ?')
day2 = input('Enter total hours on duty day2 ?')
day3 = input('Enter total hours on duty day3 ?')
day4 = input('Enter total hours on duty day4 ?')
day5 = input('Enter total hours on duty day5 ?')
day6 = input('Enter total hours on duty day6 ?')
day7 = input('Enter total hours on duty day7 ?')
day8 = input('Enter total hours on duty day8 ?')

# create list to keep track of changing values 

historyList = [day1,day2,day3,day4,day5,day6,day7,day8]
nextDay = 0
Continue = 0

# create loop for additional days input

print
Continue = raw_input ('do you wish to continue adding days ? y/n  : ' )
while Continue != 'n':
    print
    nextDay = input('enter hours on duty next day :  ')
    historyList.append(nextDay)
    print
    Continue = raw_input ('do you wish to continue adding days? y/n  : ' )
if Continue == 'n':
    print
    
print "                                 RECAP"
print "----------------------------------------------------------------------
---------"
print  
 
# output running totals when user is done inputing data

print "total hours on duty last 7 Days: " , historyList [-1 ] + historyList[-
2]+ historyList[-3]+ historyList[-4]\
+ historyList[-5]+ historyList[-6]+ historyList[-7]

# create a variable containing the last 7 days concurrently

last7Days = historyList [-1 ] + historyList[-2]+ historyList[-3]+ 
historyList[-4]\
+ historyList[-5]+ historyList[-6]+ historyList[-7]


print
print "total hours avalible  tomorrow:  " , 70 - last7Days
print
print "total hours on duty last 8 Days: ", last7Days + historyList [-8]
print

# output number of days entered

print "You have entered  ",  len (historyList), " Days"
print

# output list of hours from input

print historyList [0:100]
print
print "      Have a Safe Trip :-) "
print
print
print