Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- capacitateVagonCalatori = 80
- greutatePersoana = 0.08
- incasarePerCalator = 100
- capacitateVagonMarfaTonaj = 50
- capacitateVagonMarfaVolum = 300
- incasareTona = 40
- putereLocomotiva = 1000
- costLocomotiva = 1000
- densitateCereale = 0.6
- densitateCombustibil = 0.84
- densitateCiment = 2.4
- densitateLichide = 1
- densitateLemn = 9.2
- densitateCarbune = 1.6
- densitateSpuma = 0.32
- nrPersMinim = 30
- tonajminim = 100
- masavagcalatori = 85
- masavagmarfa = 55
- distanta = 480
- def citire():
- p = int(input("Introduceti nr calatori="))
- tc = float(input("Introduceti tonaj cereale="))
- tcbl = float(input("Introduceti tonaj combustibili="))
- tcm = float(input("Introduceti tonaj ciment="))
- tlc = float(input("Introduceti tonaj lichide="))
- tlm = float(input("Introduceti tonaj lemn="))
- tcb = float(input("Introduceti tonaj carbune="))
- ts = float(input("Introduceti tonaj spuma poliuretanica="))
- t = (p, tc, tcbl, tcm, tlc, tlm, tcb, ts)
- return t
- def validare(t):
- s = t[1] + t[2] + t[3] + t[4] + t[5] + t[6] + t[7]
- if t[0] >= nrPersMinim and s >= tonajminim:
- return True
- else:
- return False
- def afisare(t):
- print(
- "Trenul are {} calatori si marfa(in tone): {} cereale, {} combustibili, {} ciment, {} lichide, {} lemn, {} carbune, {} spuma poliuretanica".format(
- t[0], t[1], t[2], t[3], t[4], t[5], t[6], t[7]))
- def determinareNrVagoanePers(t):
- nrvc = None
- if t[0] % capacitateVagonCalatori == 0:
- nrvc = t[0] // capacitateVagonCalatori
- else:
- nrvc = t[0] // capacitateVagonCalatori + 1
- return nrvc
- def determinareNrVagoaneMarfa(t):
- k = 0
- volumCereale = t[1] / densitateCereale
- cereale1 = volumCereale / capacitateVagonMarfaVolum
- cereale2 = volumCereale // capacitateVagonMarfaVolum
- if cereale1 == cereale2 and cereale1 != 0:
- k = k + cereale2
- elif cereale1 != cereale2:
- k = k + 1 + cereale2
- volumCombustibil = t[2] / densitateCombustibil
- combustibil1 = volumCombustibil / capacitateVagonMarfaVolum
- combustibil2 = volumCombustibil // capacitateVagonMarfaVolum
- if combustibil1 == combustibil2 and combustibil1 != 0:
- k = k + combustibil2
- elif combustibil1 != combustibil2:
- k = k + 1 + combustibil2
- volumCiment = t[3] / densitateCiment
- ciment1 = volumCiment / capacitateVagonMarfaVolum
- ciment2 = volumCiment // capacitateVagonMarfaVolum
- if ciment1 == ciment2 and ciment1 != 0:
- k = k + ciment2
- elif ciment1 != ciment2:
- k = k + 1 + ciment2
- volumLichide = t[4] / densitateLichide
- lichide1 = volumLichide / capacitateVagonMarfaVolum
- lichide2 = volumLichide // capacitateVagonMarfaVolum
- if lichide1 == lichide2 and lichide1 != 0:
- k = k + lichide2
- elif lichide1 != lichide2:
- k = k + 1 + lichide2
- volumLemn = t[5] / densitateLemn
- lemn1 = volumLemn / capacitateVagonMarfaVolum
- lemn2 = volumLemn // capacitateVagonMarfaVolum
- if lemn1 == lemn2 and lemn1 != 0:
- k = k + lemn2
- elif lemn1 != lemn2:
- k = k + 1 + lemn2
- volumCarbune = t[6] / densitateCarbune
- carbune1 = volumCarbune / capacitateVagonMarfaVolum
- carbune2 = volumCarbune // capacitateVagonMarfaVolum
- if carbune1 == carbune2 and carbune1 != 0:
- k = k + carbune2
- elif carbune1 != carbune2:
- k = k + 1 + carbune2
- volumSpuma = t[7] / densitateSpuma
- spuma1 = volumSpuma / capacitateVagonMarfaVolum
- spuma2 = volumSpuma // capacitateVagonMarfaVolum
- if spuma1 == spuma2 and spuma1 != 0:
- k = k + spuma2
- elif spuma1 != spuma2:
- k = k + 1 + spuma2
- return k
- def determinareNrLocomotive (tupla):
- greutatePersoane = tupla[0] * greutatePersoana
- greutateMarfa = 0
- for i in range (1, len (tupla)):
- greutateMarfa = greutateMarfa + tupla [i]
- greutateVagoanePersoane = determinareNrVagoanePers (tupla) * masavagcalatori
- greutateVagoaneMarfa = determinareNrVagoaneMarfa (tupla) * masavagmarfa
- total=greutatePersoane + greutateMarfa + greutateVagoanePersoane + greutateVagoaneMarfa
- if total % putereLocomotiva == 0:
- return total // putereLocomotiva
- else:
- return (total//putereLocomotiva + 1)
- def incasariCalatori (tupla):
- return tupla [0] * incasarePerCalator * (distanta / 100)
- def incasariMarfa (tupla):
- total = 0
- for i in range (1, len (tupla)):
- total = total + tupla [i]
- return total * incasareTona * (distanta / 100)
- def costuri (nrLocomotive):
- return nrLocomotive * costLocomotiva * (distanta/100)
- def profit (incasariCalatori, incasariMarfa, costuri):
- p=incasariCalatori + incasariMarfa - costuri
- return p
- tren=citire()
- if validare (tren) == True:
- afisare (tren)
- sCalatori = incasariCalatori (tren)
- sMarfa = incasariMarfa (tren)
- nrLocomotive = determinareNrLocomotive (tren)
- costuri = costuri (nrLocomotive)
- margin = profit (sCalatori, sMarfa, costuri)
- print ("Profitul calatoriei ={}". format (margin))
Add Comment
Please, Sign In to add comment