6
\$\begingroup\$

I'm new to coding but I'm particularly new to python. I wrote a program that will determine a diver's table and schedule(because it relates to my job). It essentially assigns a value from multiple lists based on a given int(bottom time), and another given int(depth) as well as a given string associated with those to ints. I spent a lot of time typing this all out and I couldn't help but think there's probably a better way to do this. I'm hoping you can help me.

#This program is intended for No-Decompression dives. Do not use for decompression
# or repet dives!

#final bottom time
fbt = 0
#final max depth
fmd = 0
print("WARNING! This program will not properly compute decompression or exceptional exposure dives!")
#prompts the user to enter the max depth and bottom time of the dive
md = int(input("What is the max depth of the dive in feet? "))
bt = int(input("What is the total bottom time of the dive in minutes? "))
repet_des = "A"
#lists of tables/depths/repet designators
repet = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "Z"]
depths = [10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190]
ten_fsw = [57 , 101, 158, 245, 426]
fifteen_fsw = [36, 60, 88, 121, 163, 271, 297, 449]
twenty_fsw = [26, 43, 61, 82, 106, 133, 165, 205, 256, 330, 416]
twenty_five_fsw = [20, 33, 47, 62, 78, 97, 117, 140, 166, 198, 236, 285, 354, 469, 992, 1102]
thirty_fsw = [17, 27, 38, 50, 62, 76, 91, 107, 125, 145, 167, 193, 223, 260, 307, 371]
thirty_five_fsw = [14, 23, 32, 42, 52, 63, 74, 87, 100, 115, 131, 148, 168, 190, 215, 232]
fourty_fsw = [12, 20, 27, 36, 44, 53, 63, 73, 84, 95, 108, 121, 135, 151, 163]
fourty_five_fsw = [11, 17, 24, 31, 39, 46, 55, 63, 72, 82, 92, 102, 114, 125]
fifty_fsw = [9, 15, 21, 28, 34, 41, 48, 56, 63, 71, 80, 89, 92]
fifty_five_fsw = [8, 14, 19, 25, 31, 37, 43, 50, 56, 63, 71, 74]
sixty_fsw = [7, 12, 17, 22, 28, 33, 39, 45, 51, 57, 63]
seventy_fsw = [6, 10, 14, 19, 23, 28, 32, 37, 42, 47, 4]
eighty_fsw = [5, 9, 12, 16, 20, 24, 28, 32, 36, 39]
ninety_fsw = [4, 7, 11, 14, 17, 21, 24, 28, 31, 33]
one_hundred_fsw = [4, 6, 9, 12, 15, 18, 21, 2]
one_hundred_ten_fsw = [3, 6, 8, 11, 14, 16, 19, 20]
one_hundred_twenty_fsw = [3, 5, 7, 10, 12, 15]
one_hundred_thirty_fsw = [2, 4, 6, 9, 11, 12]
one_hundred_fourty_fsw = [2, 4, 6, 8, 10]
one_hundred_fifty_fsw = [3, 5, 7, 8]
one_hundred_sixty_fsw = [3, 5, 6, 7]
one_hundred_seventy_fsw = [4, 6]
one_hundred_eighty_fsw = [4, 5, 6]
one_hundred_ninety_fsw = [3, 5]
#Calculates T/S if MD is 10 or less.
if md <= depths[0]:
        fmd = depths[0]
        if bt <= ten_fsw[0]:
            fbt = ten_fsw[0]
            repet_des = repet[0]
        elif bt > ten_fsw[0] and bt <= ten_fsw[1]:
            fbt = ten_fsw[1]
            repet_des = repet[1]
        elif bt > ten_fsw[1] and bt <= ten_fsw[2]:
            fbt = ten_fsw[2]
            repet_des = repet[2]
        elif bt > ten_fsw[2] and bt <= ten_fsw[3]:
            fbt = ten_fsw[3]
            repet_des = repet[3]
        elif bt > ten_fsw[3]:
            fbt = ten_fsw[4]
            repet_des = repet[4]
#Calculates T/S if MD is 15 or less.
elif md <= depths[1]:
    fmd = depths[1]
    if bt <= fifteen_fsw[0]:
         fbt = fifteen_fsw[0]
         repet_des = repet[0]
    elif bt > fifteen_fsw[0] and bt <= fifteen_fsw[1]:
            fbt = fifteen_fsw[1]
            repet_des = repet[1]
    elif bt > fifteen_fsw[1] and bt <= fifteen_fsw[2]:
            fbt = fifteen_fsw[2]
            repet_des = repet[2]
    elif bt > fifteen_fsw[2] and bt <= fifteen_fsw[3]:
            fbt = fifteen_fsw[3]
            repet_des = repet[3]
    elif bt > fifteen_fsw[3] and bt <= fifteen_fsw[4]:
            fbt = fifteen_fsw[4]
            repet_des = repet[4]
    elif bt > fifteen_fsw[4] and bt <= fifteen_fsw[5]:
            fbt = fifteen_fsw[5]
            repet_des = repet[5]
    elif bt > fifteen_fsw[5] and bt <= fifteen_fsw[6]:
            fbt = fifteen_fsw[6]
            repet_des = repet[6]
    elif bt > fifteen_fsw[6]:
            fbt = fifteen_fsw[7]
            repet_des = repet[7]

#Calculates T/S if MD is 20 or less.
elif md <= depths[2]:
    fmd = depths[2]
    if bt <= twenty_fsw[0]:
         fbt = twenty_fsw[0]
         repet_des = repet[0]
    elif bt > twenty_fsw[0] and bt <= twenty_fsw[1]:
            fbt = twenty_fsw[1]
            repet_des = repet[1]
    elif bt > twenty_fsw[1] and bt <= twenty_fsw[2]:
            fbt = twenty_fsw[2]
            repet_des = repet[2]
    elif bt > twenty_fsw[2] and bt <= twenty_fsw[3]:
            fbt = twenty_fsw[3]
            repet_des = repet[3]
    elif bt > twenty_fsw[3] and bt <= twenty_fsw[4]:
            fbt = twenty_fsw[4]
            repet_des = repet[4]
    elif bt > twenty_fsw[4] and bt <= twenty_fsw[5]:
            fbt = twenty_fsw[5]
            repet_des = repet[5]
    elif bt > twenty_fsw[5] and bt <= twenty_fsw[6]:
            fbt = twenty_fsw[6]
            repet_des = repet[6]
    elif bt > twenty_fsw[6] and bt <= twenty_fsw[7]:
            fbt = twenty_fsw[7]
            repet_des = repet[7]
    elif bt > twenty_fsw[7] and bt <= twenty_fsw[8]:
            fbt = twenty_fsw[8]
            repet_des = repet[8]
    elif bt > twenty_fsw[8] and bt <= twenty_fsw[9]:
            fbt = twenty_fsw[9]
            repet_des = repet[9]
    elif bt > twenty_fsw[9]:
            fbt = twenty_fsw[10]
            repet_des = repet[10]
#Calculates T/S if MD is 25 or less.
elif md <= depths[3]:
    fmd = depths[3]
    if bt <= twenty_five_fsw[0]:
         fbt = twenty_five_fsw[0]
         repet_des = repet[0]
    elif bt > twenty_five_fsw[0] and bt <= twenty_five_fsw[1]:
            fbt = twenty_five_fsw[1]
            repet_des = repet[1]
    elif bt > twenty_five_fsw[1] and bt <= twenty_five_fsw[2]:
            fbt = twenty_five_fsw[2]
            repet_des = repet[2]
    elif bt > twenty_five_fsw[2] and bt <= twenty_five_fsw[3]:
            fbt = twenty_five_fsw[3]
            repet_des = repet[3]
    elif bt > twenty_five_fsw[3] and bt <= twenty_five_fsw[4]:
            fbt = twenty_five_fsw[4]
            repet_des = repet[4]
    elif bt > twenty_five_fsw[4] and bt <= twenty_five_fsw[5]:
            fbt = twenty_five_fsw[5]
            repet_des = repet[5]
    elif bt > twenty_five_fsw[5] and bt <= twenty_five_fsw[6]:
            fbt = twenty_five_fsw[6]
            repet_des = repet[6]
    elif bt > twenty_five_fsw[6] and bt <= twenty_five_fsw[7]:
            fbt = twenty_five_fsw[7]
            repet_des = repet[7]
    elif bt > twenty_five_fsw[7] and bt <= twenty_five_fsw[8]:
            fbt = twenty_five_fsw[8]
            repet_des = repet[8]
    elif bt > twenty_five_fsw[8] and bt <= twenty_five_fsw[9]:
            fbt = twenty_five_fsw[9]
            repet_des = repet[9]
    elif bt > twenty_five_fsw[9] and bt <= twenty_five_fsw[10]:
            fbt = twenty_five_fsw[10]
            repet_des = repet[10]
    elif bt > twenty_five_fsw[10] and bt <= twenty_five_fsw[11]:
            fbt = twenty_five_fsw[11]
            repet_des = repet[11]
    elif bt > twenty_five_fsw[11] and bt <= twenty_five_fsw[12]:
            fbt = twenty_five_fsw[12]
            repet_des = repet[12]
    elif bt > twenty_five_fsw[12] and bt <= twenty_five_fsw[13]:
            fbt = twenty_five_fsw[13]
            repet_des = repet[13]
    elif bt > twenty_five_fsw[13] and bt <= twenty_five_fsw[14]:
            fbt = twenty_five_fsw[14]
            repet_des = repet[14]
    elif bt > twenty_five_fsw[14]:
            fbt = twenty_five_fsw[15]
            repet_des = repet[15]
elif md <= depths[4]:
    fmd = depths[4]
    if bt <= thirty_fsw[0]:
         fbt = thirty_fsw[0]
         repet_des = repet[0]
    elif bt > thirty_fsw[0] and bt <= thirty_fsw[1]:
            fbt = thirty_fsw[1]
            repet_des = repet[1]
    elif bt > thirty_fsw[1] and bt <= thirty_fsw[2]:
            fbt = thirty_fsw[2]
            repet_des = repet[2]
    elif bt > thirty_fsw[2] and bt <= thirty_fsw[3]:
            fbt = thirty_fsw[3]
            repet_des = repet[3]
    elif bt > thirty_fsw[3] and bt <= thirty_fsw[4]:
            fbt = thirty_fsw[4]
            repet_des = repet[4]
    elif bt > thirty_fsw[4] and bt <= thirty_fsw[5]:
            fbt = thirty_fsw[5]
            repet_des = repet[5]
    elif bt > thirty_fsw[5] and bt <= thirty_fsw[6]:
            fbt = thirty_fsw[6]
            repet_des = repet[6]
    elif bt > thirty_fsw[6] and bt <= thirty_fsw[7]:
            fbt = thirty_fsw[7]
            repet_des = repet[7]
    elif bt > thirty_fsw[7] and bt <= thirty_fsw[8]:
            fbt = thirty_fsw[8]
            repet_des = repet[8]
    elif bt > thirty_fsw[8] and bt <= thirty_fsw[9]:
            fbt = thirty_fsw[9]
            repet_des = repet[9]
    elif bt > thirty_fsw[9] and bt <= thirty_fsw[10]:
            fbt = thirty_fsw[10]
            repet_des = repet[10]
    elif bt > thirty_fsw[10] and bt <= thirty_fsw[11]:
            fbt = thirty_fsw[11]
            repet_des = repet[11]
    elif bt > thirty_fsw[11] and bt <= thirty_fsw[12]:
            fbt = thirty_fsw[12]
            repet_des = repet[12]
    elif bt > thirty_fsw[12] and bt <= thirty_fsw[13]:
            fbt = thirty_fsw[13]
            repet_des = repet[13]
    elif bt > thirty_fsw[13] and bt <= thirty_fsw[14]:
            fbt = thirty_fsw[14]
            repet_des = repet[14]
    elif bt > thirty_fsw[14]:
            fbt = thirty_fsw[15]
            repet_des = repet[15]
#Calculates T/S if MD is 35 or less.
elif md <= depths[5]:
    fmd = depths[5]
    if bt <= thirty_five_fsw[0]:
         fbt = thirty_five_fsw[0]
         repet_des = repet[0]
    elif bt > thirty_five_fsw[0] and bt <= thirty_five_fsw[1]:
            fbt = thirty_five_fsw[1]
            repet_des = repet[1]
    elif bt > thirty_five_fsw[1] and bt <= thirty_five_fsw[2]:
            fbt = thirty_five_fsw[2]
            repet_des = repet[2]
    elif bt > thirty_five_fsw[2] and bt <= thirty_five_fsw[3]:
            fbt = thirty_five_fsw[3]
            repet_des = repet[3]
    elif bt > thirty_five_fsw[3] and bt <= thirty_five_fsw[4]:
            fbt = thirty_five_fsw[4]
            repet_des = repet[4]
    elif bt > thirty_five_fsw[4] and bt <= thirty_five_fsw[5]:
            fbt = thirty_five_fsw[5]
            repet_des = repet[5]
    elif bt > thirty_five_fsw[5] and bt <= thirty_five_fsw[6]:
            fbt = thirty_five_fsw[6]
            repet_des = repet[6]
    elif bt > thirty_five_fsw[6] and bt <= thirty_five_fsw[7]:
            fbt = thirty_five_fsw[7]
            repet_des = repet[7]
    elif bt > thirty_five_fsw[7] and bt <= thirty_five_fsw[8]:
            fbt = thirty_five_fsw[8]
            repet_des = repet[8]
    elif bt > thirty_five_fsw[8] and bt <= thirty_five_fsw[9]:
            fbt = thirty_five_fsw[9]
            repet_des = repet[9]
    elif bt > thirty_five_fsw[9] and bt <= thirty_five_fsw[10]:
            fbt = thirty_five_fsw[10]
            repet_des = repet[10]
    elif bt > thirty_five_fsw[10] and bt <= thirty_five_fsw[11]:
            fbt = thirty_five_fsw[11]
            repet_des = repet[11]
    elif bt > thirty_five_fsw[11] and bt <= thirty_five_fsw[12]:
            fbt = thirty_five_fsw[12]
            repet_des = repet[12]
    elif bt > thirty_five_fsw[12] and bt <= thirty_five_fsw[13]:
            fbt = thirty_five_fsw[13]
            repet_des = repet[13]
    elif bt > thirty_five_fsw[13] and bt <= thirty_five_fsw[14]:
            fbt = thirty_five_fsw[14]
            repet_des = repet[14]
    elif bt > thirty_five_fsw[14]:
            fbt = thirty_five_fsw[15]
            repet_des = repet[15]
#Calculates T/S if MD is 40 or less.
elif md <= depths[6]:
    fmd = depths[6]
    if bt <= fourty_fsw[0]:
         fbt = fourty_fsw[0]
         repet_des = repet[0]
    elif bt > fourty_fsw[0] and bt <= fourty_fsw[1]:
            fbt = fourty_fsw[1]
            repet_des = repet[1]
    elif bt > fourty_fsw[1] and bt <= fourty_fsw[2]:
            fbt = fourty_fsw[2]
            repet_des = repet[2]
    elif bt > fourty_fsw[2] and bt <= fourty_fsw[3]:
            fbt = fourty_fsw[3]
            repet_des = repet[3]
    elif bt > fourty_fsw[3] and bt <= fourty_fsw[4]:
            fbt = fourty_fsw[4]
            repet_des = repet[4]
    elif bt > fourty_fsw[4] and bt <= fourty_fsw[5]:
            fbt = fourty_fsw[5]
            repet_des = repet[5]
    elif bt > fourty_fsw[5] and bt <= fourty_fsw[6]:
            fbt = fourty_fsw[6]
            repet_des = repet[6]
    elif bt > fourty_fsw[6] and bt <= fourty_fsw[7]:
            fbt = fourty_fsw[7]
            repet_des = repet[7]
    elif bt > fourty_fsw[7] and bt <= fourty_fsw[8]:
            fbt = fourty_fsw[8]
            repet_des = repet[8]
    elif bt > fourty_fsw[8] and bt <= fourty_fsw[9]:
            fbt = fourty_fsw[9]
            repet_des = repet[9]
    elif bt > fourty_fsw[9] and bt <= fourty_fsw[10]:
            fbt = fourty_fsw[10]
            repet_des = repet[10]
    elif bt > fourty_fsw[10] and bt <= fourty_fsw[11]:
            fbt = fourty_fsw[11]
            repet_des = repet[11]
    elif bt > fourty_fsw[11] and bt <= fourty_fsw[12]:
            fbt = fourty_fsw[12]
            repet_des = repet[12]
    elif bt > fourty_fsw[12] and bt <= fourty_fsw[13]:
            fbt = fourty_fsw[13]
            repet_des = repet[13]
    elif bt > fourty_fsw[13]:
            fbt = fourty_fsw[14]
            repet_des = repet[14]
#Calculates T/S if MD is 45 or less.
elif md <= depths[7]:
    fmd = depths[7]
    if bt <= fourty_five_fsw[0]:
         fbt = fourty_five_fsw[0]
         repet_des = repet[0]
    elif bt > fourty_five_fsw[0] and bt <= fourty_five_fsw[1]:
            fbt = fourty_five_fsw[1]
            repet_des = repet[1]
    elif bt > fourty_five_fsw[1] and bt <= fourty_five_fsw[2]:
            fbt = fourty_five_fsw[2]
            repet_des = repet[2]
    elif bt > fourty_five_fsw[2] and bt <= fourty_five_fsw[3]:
            fbt = fourty_five_fsw[3]
            repet_des = repet[3]
    elif bt > fourty_five_fsw[3] and bt <= fourty_five_fsw[4]:
            fbt = fourty_five_fsw[4]
            repet_des = repet[4]
    elif bt > fourty_five_fsw[4] and bt <= fourty_five_fsw[5]:
            fbt = fourty_five_fsw[5]
            repet_des = repet[5]
    elif bt > fourty_five_fsw[5] and bt <= fourty_five_fsw[6]:
            fbt = fourty_five_fsw[6]
            repet_des = repet[6]
    elif bt > fourty_five_fsw[6] and bt <= fourty_five_fsw[7]:
            fbt = fourty_five_fsw[7]
            repet_des = repet[7]
    elif bt > fourty_five_fsw[7] and bt <= fourty_five_fsw[8]:
            fbt = fourty_five_fsw[8]
            repet_des = repet[8]
    elif bt > fourty_five_fsw[8] and bt <= fourty_five_fsw[9]:
            fbt = fourty_five_fsw[9]
            repet_des = repet[9]
    elif bt > fourty_five_fsw[9] and bt <= fourty_five_fsw[10]:
            fbt = fourty_five_fsw[10]
            repet_des = repet[10]
    elif bt > fourty_five_fsw[10] and bt <= fourty_five_fsw[11]:
            fbt = fourty_five_fsw[11]
            repet_des = repet[11]
    elif bt > fourty_five_fsw[11] and bt <= fourty_five_fsw[12]:
            fbt = fourty_five_fsw[12]
            repet_des = repet[12]
    elif bt > fourty_five_fsw[12]:
            fbt = fourty_five_fsw[13]
            repet_des = repet[13]
#Calculates T/S if MD is 50 or less.
elif md <= depths[8]:
    fmd = depths[8]
    if bt <= fifty_fsw[0]:
         fbt = fifty_fsw[0]
         repet_des = repet[0]
    elif bt > fifty_fsw[0] and bt <= fifty_fsw[1]:
            fbt = fifty_fsw[1]
            repet_des = repet[1]
    elif bt > fifty_fsw[1] and bt <= fifty_fsw[2]:
            fbt = fifty_fsw[2]
            repet_des = repet[2]
    elif bt > fifty_fsw[2] and bt <= fifty_fsw[3]:
            fbt = fifty_fsw[3]
            repet_des = repet[3]
    elif bt > fifty_fsw[3] and bt <= fifty_fsw[4]:
            fbt = fifty_fsw[4]
            repet_des = repet[4]
    elif bt > fifty_fsw[4] and bt <= fifty_fsw[5]:
            fbt = fifty_fsw[5]
            repet_des = repet[5]
    elif bt > fifty_fsw[5] and bt <= fifty_fsw[6]:
            fbt = fifty_fsw[6]
            repet_des = repet[6]
    elif bt > fifty_fsw[6] and bt <= fifty_fsw[7]:
            fbt = fifty_fsw[7]
            repet_des = repet[7]
    elif bt > fifty_fsw[7] and bt <= fifty_fsw[8]:
            fbt = fifty_fsw[8]
            repet_des = repet[8]
    elif bt > fifty_fsw[8] and bt <= fifty_fsw[9]:
            fbt = fifty_fsw[9]
            repet_des = repet[9]
    elif bt > fifty_fsw[9] and bt <= fifty_fsw[10]:
            fbt = fifty_fsw[10]
            repet_des = repet[10]
    elif bt > fifty_fsw[10] and bt <= fifty_fsw[11]:
            fbt = fifty_fsw[11]
            repet_des = repet[11]
    elif bt > fifty_fsw[11]:
            fbt = fifty_fsw[12]
            repet_des = repet[12]
#Calculates T/S if MD is 55 or less.
elif md <= depths[9]:
    fmd = depths[10]
    if bt <= fifty_five_fsw[0]:
         fbt = fifty_five_fsw[0]
         repet_des = repet[0]
    elif bt > fifty_five_fsw[0] and bt <= fifty_five_fsw[1]:
            fbt = fifty_five_fsw[1]
            repet_des = repet[1]
    elif bt > fifty_five_fsw[1] and bt <= fifty_five_fsw[2]:
            fbt = fifty_five_fsw[2]
            repet_des = repet[2]
    elif bt > fifty_five_fsw[2] and bt <= fifty_five_fsw[3]:
            fbt = fifty_five_fsw[3]
            repet_des = repet[3]
    elif bt > fifty_five_fsw[3] and bt <= fifty_five_fsw[4]:
            fbt = fifty_five_fsw[4]
            repet_des = repet[4]
    elif bt > fifty_five_fsw[4] and bt <= fifty_five_fsw[5]:
            fbt = fifty_five_fsw[5]
            repet_des = repet[5]
    elif bt > fifty_five_fsw[5] and bt <= fifty_five_fsw[6]:
            fbt = fifty_five_fsw[6]
            repet_des = repet[6]
    elif bt > fifty_five_fsw[6] and bt <= fifty_five_fsw[7]:
            fbt = fifty_five_fsw[7]
            repet_des = repet[7]
    elif bt > fifty_five_fsw[7] and bt <= fifty_five_fsw[8]:
            fbt = fifty_five_fsw[8]
            repet_des = repet[8]
    elif bt > fifty_five_fsw[8] and bt <= fifty_five_fsw[9]:
            fbt = fifty_five_fsw[9]
            repet_des = repet[9]
    elif bt > fifty_five_fsw[9] and bt <= fifty_five_fsw[10]:
            fbt = fifty_five_fsw[10]
            repet_des = repet[10]
    elif bt > fifty_five_fsw[10]:
            fbt = fifty_five_fsw[11]
            repet_des = repet[11]
#Calculates T/S if MD is 60 or less.
elif md <= depths[10]:
    fmd = depths[11]
    if bt <= sixty_fsw[0]:
         fbt = sixty_fsw[0]
         repet_des = repet[0]
    elif bt > sixty_fsw[0] and bt <= sixty_fsw[1]:
            fbt = sixty_fsw[1]
            repet_des = repet[1]
    elif bt > sixty_fsw[1] and bt <= sixty_fsw[2]:
            fbt = sixty_fsw[2]
            repet_des = repet[2]
    elif bt > sixty_fsw[2] and bt <= sixty_fsw[3]:
            fbt = sixty_fsw[3]
            repet_des = repet[3]
    elif bt > sixty_fsw[3] and bt <= sixty_fsw[4]:
            fbt = sixty_fsw[4]
            repet_des = repet[4]
    elif bt > sixty_fsw[4] and bt <= sixty_fsw[5]:
            fbt = sixty_fsw[5]
            repet_des = repet[5]
    elif bt > sixty_fsw[5] and bt <= sixty_fsw[6]:
            fbt = sixty_fsw[6]
            repet_des = repet[6]
    elif bt > sixty_fsw[6] and bt <= sixty_fsw[7]:
            fbt = sixty_fsw[7]
            repet_des = repet[7]
    elif bt > sixty_fsw[7] and bt <= sixty_fsw[8]:
            fbt = sixty_fsw[8]
            repet_des = repet[8]
    elif bt > sixty_fsw[8] and bt <= sixty_fsw[9]:
            fbt = sixty_fsw[9]
            repet_des = repet[9]
    elif bt > sixty_fsw[9]:
            fbt = sixty_fsw[10]
            repet_des = repet[10]
#Calculates T/S if MD is 70 or less.
elif md <= depths[11]:
    fmd = depths[12]
    if bt <= seventy_fsw[0]:
         fbt = seventy_fsw[0]
         repet_des = repet[0]
    elif bt > seventy_fsw[0] and bt <= seventy_fsw[1]:
            fbt = seventy_fsw[1]
            repet_des = repet[1]
    elif bt > seventy_fsw[1] and bt <= seventy_fsw[2]:
            fbt = seventy_fsw[2]
            repet_des = repet[2]
    elif bt > seventy_fsw[2] and bt <= seventy_fsw[3]:
            fbt = seventy_fsw[3]
            repet_des = repet[3]
    elif bt > seventy_fsw[3] and bt <= seventy_fsw[4]:
            fbt = seventy_fsw[4]
            repet_des = repet[4]
    elif bt > seventy_fsw[4] and bt <= seventy_fsw[5]:
            fbt = seventy_fsw[5]
            repet_des = repet[5]
    elif bt > seventy_fsw[5] and bt <= seventy_fsw[6]:
            fbt = seventy_fsw[6]
            repet_des = repet[6]
    elif bt > seventy_fsw[6] and bt <= seventy_fsw[7]:
            fbt = seventy_fsw[7]
            repet_des = repet[7]
    elif bt > seventy_fsw[7] and bt <= seventy_fsw[8]:
            fbt = seventy_fsw[8]
            repet_des = repet[8]
    elif bt > seventy_fsw[8] and bt <= seventy_fsw[9]:
            fbt = seventy_fsw[9]
            repet_des = repet[9]
    elif bt > seventy_fsw[9]:
            fbt = seventy_fsw[10]
            repet_des = repet[10]
##Calculates T/S if MD is 80 or less.
elif md <= depths[12]:
    fmd = depths[12]
    if bt <= eighty_fsw[0]:
         fbt = eighty_fsw[0]
         repet_des = repet[0]
    elif bt > eighty_fsw[0] and bt <= eighty_fsw[1]:
            fbt = eighty_fsw[1]
            repet_des = repet[1]
    elif bt > eighty_fsw[1] and bt <= eighty_fsw[2]:
            fbt = eighty_fsw[2]
            repet_des = repet[2]
    elif bt > eighty_fsw[2] and bt <= eighty_fsw[3]:
            fbt = eighty_fsw[3]
            repet_des = repet[3]
    elif bt > eighty_fsw[3] and bt <= eighty_fsw[4]:
            fbt = eighty_fsw[4]
            repet_des = repet[4]
    elif bt > eighty_fsw[4] and bt <= eighty_fsw[5]:
            fbt = eighty_fsw[5]
            repet_des = repet[5]
    elif bt > eighty_fsw[5] and bt <= eighty_fsw[6]:
            fbt = eighty_fsw[6]
            repet_des = repet[6]
    elif bt > eighty_fsw[6] and bt <= eighty_fsw[7]:
            fbt = eighty_fsw[7]
            repet_des = repet[7]
    elif bt > eighty_fsw[7] and bt <= eighty_fsw[8]:
            fbt = eighty_fsw[8]
            repet_des = repet[8]
    elif bt > eighty_fsw[8]:
            fbt = eighty_fsw[9]
            repet_des = repet[9]
##Calculates T/S if MD is 90 or less.
elif md <= depths[13]:
    fmd = depths[13]
    if bt <= ninety_fsw[0]:
         fbt = ninety_fsw[0]
         repet_des = repet[0]
    elif bt > ninety_fsw[0] and bt <= ninety_fsw[1]:
            fbt = ninety_fsw[1]
            repet_des = repet[1]
    elif bt > ninety_fsw[1] and bt <= ninety_fsw[2]:
            fbt = ninety_fsw[2]
            repet_des = repet[2]
    elif bt > ninety_fsw[2] and bt <= ninety_fsw[3]:
            fbt = ninety_fsw[3]
            repet_des = repet[3]
    elif bt > ninety_fsw[3] and bt <= ninety_fsw[4]:
            fbt = ninety_fsw[4]
            repet_des = repet[4]
    elif bt > ninety_fsw[4] and bt <= ninety_fsw[5]:
            fbt = ninety_fsw[5]
            repet_des = repet[5]
    elif bt > ninety_fsw[5] and bt <= ninety_fsw[6]:
            fbt = ninety_fsw[6]
            repet_des = repet[6]
    elif bt > ninety_fsw[6] and bt <= ninety_fsw[7]:
            fbt = ninety_fsw[7]
            repet_des = repet[7]
    elif bt > ninety_fsw[7] and bt <= ninety_fsw[8]:
            fbt = ninety_fsw[8]
            repet_des = repet[8]
    elif bt > ninety_fsw[8]:
            fbt = ninety_fsw[9]
            repet_des = repet[9]
##Calculates T/S if MD is 100 or less.
elif md <= depths[14]:
    fmd = depths[14]
    if bt <= one_hundred_fsw[0]:
         fbt = one_hundred_fsw[0]
         repet_des = repet[0]
    elif bt > one_hundred_fsw[0] and bt <= one_hundred_fsw[1]:
            fbt = one_hundred_fsw[1]
            repet_des = repet[1]
    elif bt > one_hundred_fsw[1] and bt <= one_hundred_fsw[2]:
            fbt = one_hundred_fsw[2]
            repet_des = repet[2]
    elif bt > one_hundred_fsw[2] and bt <= one_hundred_fsw[3]:
            fbt = one_hundred_fsw[3]
            repet_des = repet[3]
    elif bt > one_hundred_fsw[3] and bt <= one_hundred_fsw[4]:
            fbt = one_hundred_fsw[4]
            repet_des = repet[4]
    elif bt > one_hundred_fsw[4] and bt <= one_hundred_fsw[5]:
            fbt = one_hundred_fsw[5]
            repet_des = repet[5]
    elif bt > one_hundred_fsw[5] and bt <= one_hundred_fsw[6]:
            fbt = one_hundred_fsw[6]
            repet_des = repet[6]
    elif bt > one_hundred_fsw[6]:
            fbt = one_hundred_fsw[7]
            repet_des = repet[7]
    ##Calculates T/S if MD is 110 or less.
elif md <= depths[15]:
    fmd = depths[15]
    if bt <= one_hundred_ten_fsw[0]:
        fbt = one_hundred_ten_fsw[0]
        repet_des = repet[0]
    elif bt > one_hundred_ten_fsw[0] and bt <= one_hundred_ten_fsw[1]:
        fbt = one_hundred_ten_fsw[1]
        repet_des = repet[1]
    elif bt > one_hundred_ten_fsw[1] and bt <= one_hundred_ten_fsw[2]:
        fbt = one_hundred_ten_fsw[2]
        repet_des = repet[2]
    elif bt > one_hundred_ten_fsw[2] and bt <= one_hundred_ten_fsw[3]:
        fbt = one_hundred_ten_fsw[3]
        repet_des = repet[3]
    elif bt > one_hundred_ten_fsw[3] and bt <= one_hundred_ten_fsw[4]:
        fbt = one_hundred_ten_fsw[4]
        repet_des = repet[4]
    elif bt > one_hundred_ten_fsw[4] and bt <= one_hundred_ten_fsw[5]:
        fbt = one_hundred_ten_fsw[5]
        repet_des = repet[5]
    elif bt > one_hundred_ten_fsw[5] and bt <= one_hundred_ten_fsw[6]:
        fbt = one_hundred_ten_fsw[6]
        repet_des = repet[6]
    elif bt > one_hundred_ten_fsw[6]:
        fbt = one_hundred_ten_fsw[7]
        repet_des = repet[7]
    ##Calculates T/S if MD is 120 or less.
elif md <= depths[16]:
    fmd = depths[16]
    if bt <= one_hundred_twenty_fsw[0]:
        fbt = one_hundred_twenty_fsw[0]
        repet_des = repet[0]
    elif bt > one_hundred_twenty_fsw[0] and bt <= one_hundred_twenty_fsw[1]:
        fbt = one_hundred_twenty_fsw[1]
        repet_des = repet[1]
    elif bt > one_hundred_twenty_fsw[1] and bt <= one_hundred_twenty_fsw[2]:
        fbt = one_hundred_twenty_fsw[2]
        repet_des = repet[2]
    elif bt > one_hundred_twenty_fsw[2] and bt <= one_hundred_twenty_fsw[3]:
        fbt = one_hundred_twenty_fsw[3]
        repet_des = repet[3]
    elif bt > one_hundred_twenty_fsw[3] and bt <= one_hundred_twenty_fsw[4]:
        fbt = one_hundred_twenty_fsw[4]
        repet_des = repet[4]
    elif bt > one_hundred_twenty_fsw[4]:
        fbt = one_hundred_twenty_fsw[5]
        repet_des = repet[5]
##Calculates T/S if MD is 130 or less.
elif md <= depths[17]:
    fmd = depths[17]
    if bt <= one_hundred_thirty_fsw[0]:
        fbt = one_hundred_thirty_fsw[0]
        repet_des = repet[0]
    elif bt > one_hundred_thirty_fsw[0] and bt <= one_hundred_thirty_fsw[1]:
        fbt = one_hundred_thirty_fsw[1]
        repet_des = repet[1]
    elif bt > one_hundred_thirty_fsw[1] and bt <= one_hundred_thirty_fsw[2]:
        fbt = one_hundred_thirty_fsw[2]
        repet_des = repet[2]
    elif bt > one_hundred_thirty_fsw[2] and bt <= one_hundred_thirty_fsw[3]:
        fbt = one_hundred_thirty_fsw[3]
        repet_des = repet[3]
    elif bt > one_hundred_thirty_fsw[3] and bt <= one_hundred_thirty_fsw[4]:
        fbt = one_hundred_thirty_fsw[4]
        repet_des = repet[4]
    elif bt > one_hundred_thirty_fsw[4]:
        fbt = one_hundred_thirty_fsw[5]
        repet_des = repet[5]
##Calculates T/S if MD is 140 or less.
elif md <= depths[18]:
    fmd = depths[18]
    if bt <= one_hundred_fourty_fsw[0]:
        fbt = one_hundred_fourty_fsw[0]
        repet_des = repet[0]
    elif bt > one_hundred_fourty_fsw[0] and bt <= one_hundred_fourty_fsw[1]:
        fbt = one_hundred_fourty_fsw[1]
        repet_des = repet[1]
    elif bt > one_hundred_fourty_fsw[1] and bt <= one_hundred_fourty_fsw[2]:
        fbt = one_hundred_fourty_fsw[2]
        repet_des = repet[2]
    elif bt > one_hundred_fourty_fsw[2] and bt <= one_hundred_fourty_fsw[3]:
        fbt = one_hundred_fourty_fsw[3]
        repet_des = repet[3]
    elif bt > one_hundred_fourty_fsw[3]:
        fbt = one_hundred_fourty_fsw[4]
        repet_des = repet[4]
##Calculates T/S if MD is 150 or less.
elif md <= depths[19]:
    fmd = depths[19]
    if bt <= one_hundred_fifty_fsw[0]:
        fbt = one_hundred_fifty_fsw[0]
        repet_des = repet[0]
    elif bt > one_hundred_fifty_fsw[0] and bt <= one_hundred_fifty_fsw[1]:
        fbt = one_hundred_fifty_fsw[1]
        repet_des = repet[1]
    elif bt > one_hundred_fifty_fsw[1] and bt <= one_hundred_fifty_fsw[2]:
        fbt = one_hundred_fifty_fsw[2]
        repet_des = repet[2]
    elif bt > one_hundred_fifty_fsw[2]:
        fbt = one_hundred_fifty_fsw[3]
        repet_des = repet[3]

##Calculates T/S if MD is 160 or less.
elif md <= depths[20]:
    fmd = depths[20]
    if bt <= one_hundred_sixty_fsw[0]:
        fbt = one_hundred_sixty_fsw[0]
        repet_des = repet[0]
    elif bt > one_hundred_sixty_fsw[0] and bt <= one_hundred_sixty_fsw[1]:
        fbt = one_hundred_sixty_fsw[1]
        repet_des = repet[1]
    elif bt > one_hundred_sixty_fsw[1] and bt <= one_hundred_sixty_fsw[2]:
        fbt = one_hundred_sixty_fsw[2]
        repet_des = repet[2]
    elif bt > one_hundred_sixty_fsw[2]:
        fbt = one_hundred_sixty_fsw[3]
        repet_des = repet[3]
##Calculates T/S if MD is 170 or less.
elif md <= depths[21]:
    fmd = depths[21]
    if bt <= one_hundred_seventy_fsw[0]:
        fbt = one_hundred_seventy_fsw[0]
        repet_des = repet[0]
    elif bt > one_hundred_seventy_fsw[0]:
        fbt = one_hundred_seventy_fsw[1]
        repet_des = repet[1]
##Calculates T/S if MD is 180 or less.
elif md <= depths[22]:
    fmd = depths[22]
    if bt <= one_hundred_eighty_fsw[0]:
        fbt = one_hundred_eighty_fsw[0]
        repet_des = repet[0]
    elif bt > one_hundred_eighty_fsw[0] and bt <= one_hundred_eighty_fsw[1]:
        fbt = one_hundred_eighty_fsw[1]
        repet_des = repet[1]
    elif bt > one_hundred_eighty_fsw[1]:
        fbt = one_hundred_eighty_fsw[2]
        repet_des = repet[2]
##Calculates T/S if MD is 190 or less.
elif md <= depths[23]:
    fmd = depths[23]
    if bt <= one_hundred_ninety_fsw[0]:
        fbt = one_hundred_ninety_fsw[0]
        repet_des = repet[0]
    elif bt > one_hundred_ninety_fsw[0] and bt <= one_hundred_ninety_fsw[1]:
        fbt = one_hundred_ninety_fsw[1]
        repet_des = repet[1]

print("The table and schedule for the diver is:" + str(fmd) + "/" + str(fbt) + " " + "'" + repet_des + "'")
\$\endgroup\$
3
  • \$\begingroup\$ What does fsw stand for? \$\endgroup\$
    – Reinderien
    Jun 13 at 0:06
  • 1
    \$\begingroup\$ Feet of sea water. I'll edit the post to include the entirety of the program. \$\endgroup\$ Jun 13 at 0:56
  • \$\begingroup\$ According to your code, 4 minutes at 130 fsw gives you repet designator B, but 4 minutes at 180 fsw gives you repet desginator A. Surely the greater depth should lead to a greater repet designator. What dive table did you use? Is it one of the tables where some of the rows have blanks in column A and the numbers start in a later column? \$\endgroup\$
    – David K
    Jun 24 at 2:34

1 Answer 1

6
\$\begingroup\$

Pandas was built for this kind of thing, and you can likely get your 700+ line program down to 30 lines of Python and a CSV file. You need to eliminate all of the repetition in your code, pull out the data into a simple database, and use tools that help you.

Note that the last 4 entry in seventy_fsw is almost certainly a transcription error. I have not corrected this.

In the following application of Pandas, searchsorted is an efficient way to locate a row in a sorted series using a binary search.

CSV

depth,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,Z
10,57,101,158,245,426,,,,,,,,,,,
15,36,60,88,121,163,271,297,449,,,,,,,,
20,26,43,61,82,106,133,165,205,256,330,416,,,,,
25,20,33,47,62,78,97,117,140,166,198,236,285,354,469,992,1102
30,17,27,38,50,62,76,91,107,125,145,167,193,223,260,307,371
35,14,23,32,42,52,63,74,87,100,115,131,148,168,190,215,232
40,12,20,27,36,44,53,63,73,84,95,108,121,135,151,163,
45,11,17,24,31,39,46,55,63,72,82,92,102,114,125,,
50,9,15,21,28,34,41,48,56,63,71,80,89,92,,,
55,8,14,19,25,31,37,43,50,56,63,71,74,,,,
60,7,12,17,22,28,33,39,45,51,57,63,,,,,
70,6,10,14,19,23,28,32,37,42,47,4,,,,,
80,5,9,12,16,20,24,28,32,36,39,,,,,,
90,4,7,11,14,17,21,24,28,31,33,,,,,,
100,4,6,9,12,15,18,21,2,,,,,,,,
110,3,6,8,11,14,16,19,20,,,,,,,,
120,3,5,7,10,12,15,,,,,,,,,,
130,2,4,6,9,11,12,,,,,,,,,,
140,2,4,6,8,10,,,,,,,,,,,
150,3,5,7,8,,,,,,,,,,,,
160,3,5,6,7,,,,,,,,,,,,
170,4,6,,,,,,,,,,,,,,
180,4,5,6,,,,,,,,,,,,,
190,3,5,,,,,,,,,,,,,,

Python

import pandas as pd


def calculate_dive(max_depth: float, bottom_time: float) -> tuple[
    float,  # final max depth
    float,  # final feet-of-seawater (fsw)
    str,    # final end-of-dive group letter
]:
    """
    This function takes a max_depth and a bottom_time (from the user or
    elsewhere), and produces a tuple of three dive parameters.

    It relies on there being a dive_table.csv with rows per depth and columns per end-of-dive group.
    """

    # Use Pandas to load a comma-separated value file containing the dive table.
    params = pd.read_csv('dive_table.csv', index_col='depth')

    y = params.index.searchsorted(max_depth)  # vertical index of max_depth
    depth = params.index[y]           # Final depth at that index
    depth_row = params.iloc[y]        # Row at that depth

    x = depth_row.searchsorted(bottom_time)   # horizontal index of bottom_time
    fsw = depth_row.iloc[x]           # feet of sea water at that index
    repet_des = params.columns[x]     # group letter at that index

    return depth, fsw, repet_des


def main() -> None:
    print('WARNING! This program will not properly compute decompression or exceptional exposure dives!')

    depth, fsw, repet_des = calculate_dive(
        max_depth=float(input('What is the max depth of the dive in feet? ')),
        bottom_time=float(input('What is the total bottom time of the dive in minutes? ')),
    )
    print(
        f'The table and schedule for the diver is: '
        f"{depth}/{fsw:.0f} '{repet_des}'"
    )


if __name__ == '__main__':
    main()

Output

WARNING! This program will not properly compute decompression or exceptional exposure dives!
What is the max depth of the dive in feet? 22
What is the total bottom time of the dive in minutes? 150
The table and schedule for the diver is: 25/166 'I'
\$\endgroup\$
1
  • 1
    \$\begingroup\$ I don't fully understand what is going on here but it seems like it points me in the right direction, thank you so much! \$\endgroup\$ Jun 13 at 1:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.