def BeforeFinish(self): if(self.tipo == 1): destino = "realizada" dePara = "para" else: destino = "recibida" dePara = "de" Disc.writeContentToDisc("Llamada " + destino + " " + dePara + " " + str(self.numero) + ". Duracion: " + str(self.tiempoTotal) + "\n", "historial")
def BeforeFinish(self): if(self.tipo == 3): destino = "enviado" dePara = "para" else: destino = "recibido" dePara = "de" Disc.writeContentToDisc("Mensaje " + destino + " " + dePara + " " + self.receptor + ". Texto: " + self.texto + "\n", "mensajes")
def main(): developerInfo() try: print('Quadratic Formula and Root Solutions Program') print('') print('Enter an numerical value for A,B, and C') print('or enter a zero for A to exit program.') print('') coeffA = int(input('Enter the coefficient A: ')) while coeffA != 0: coeffB = int(input('Enter the coefficient B: ')) coeffC = int(input('Enter the coefficient C: ')) disc = Disc.discriminant(coeffA, coeffB, coeffC) SqrRoot = math.sqrt(disc) X1 = (-coeffB + SqrRoot) / (2 * coeffA) X2 = (-coeffB - SqrRoot) / (2 * coeffA) print('\nDiscriminant is: ', disc) if disc == 0: print('The equation has one real solution.') print('X1 = ', X1) print('X2 = ', X2) else: print('The equation has two real solutions.') print('X1 = ', X1) print('X2 = ', X2) print('') print('Enter another numerical value for A,B, and C') print('or enter a zero for A to exit program.') print('') coeffA = int(input('Enter the coefficient A: ')) except ValueError: print('The equation has two complex solutions.') print('but no real solutions.')
def main(): coeffA = int(input('Enter the coefficient A: ')) coeffB = int(input('Enter the coefficient B: ')) coeffC = int(input('Enter the coefficient B: ')) disc = Disc.discriminant(coeffA, coeffB, coeffC) print('\nDiscriminant is: ', disc)
def __init__(self): #CARGAR ARCHIVOS DE RAM Y DISCO A VARIABLES self.ram y self.disc (o algo asi) Disc.boot() RamController.startRam() self.simTime = 0 #Operating System self.oSystem = OS() #Simulation time CommandLineTools.Cls() while True: print "Ingrese ruta archivo input..." path = raw_input() if CommandLineTools.FileExists(path): break print "Error: El archivo no existe. Por favor intente nuevamente...\n" self.eventsList = CommandLineTools.GetInputFromPath(path) #Contains the processes that will arrive to the OS during the simulation self.StartSimulation()
def Interrupt(self): print "\n\n===SIMULACIÓN EN PAUSA===\n\n" CommandLineTools.ImprimirMenu() opcion = raw_input().strip() if opcion == "": return if opcion == "1": CommandLineTools.ImprimirInstruccionesNuevoEvento() CommandLineTools.ImprimirComandos() print "\n" parser = Parser() while True: comando = raw_input() if comando.strip() == "": break success = parser.CheckCommand(comando, self.simTime) if not success: print "Error! Input incorrecto\n" CommandLineTools.ImprimirComandos() continue self.eventsList.insert(0, success) break return if opcion == "2": Disc.printFile("contactos") elif opcion == "3": Disc.printFile("mensajes") elif opcion == "4": Disc.printFile("historial") else: return print "\n" raw_input("Presione ENTER para continuar simulación")
def AddNewElement(self, element): print "AVAILABLE SPACE ", self.available_space_in_last_block if self.available_space_in_last_block <= 0: #CREO NUEVO BLOCK Y LO AGREGO A ESTE INODO new_block = Disc.getFirstAvailableBlock() print "NEW BLOCK", new_block if new_block != -1: self.blocks.append(new_block) DiscDriver.addBlockToFile(self.filename, new_block) self.available_space_in_last_block = 513 else: return False print self.blocks print len(self.blocks) DiscDriver.appendToFile(element, self.blocks[-1]) #CUANTO ES EL TAMAÑO DEL ELEMENTO?!?!?!?!?!?!! self.available_space_in_last_block -= 3 DiscDriver.updateFreeSpaceInInode(self.filename, self.available_space_in_last_block) return True
def making_grav_points(lista): """ Create gravity points. Gravity points are same as discs, but in one, concrete position. :param lista: list of gravity points that will be created :return: list of created gravity points """ grav_points_list = [] grav_point_pos = lista[1] for one_grav_point in grav_point_pos: grav_point = Disc() grav_point.m = 40 grav_point.r = 10 grav_point.color = (0, 0, 0) grav_point.disc_pos = [one_grav_point[0], one_grav_point[1]] grav_points_list.append(grav_point) return grav_points_list
def main(): coeffA = int(input('Enter the coefficient A: ')) if coeffA == 0: raise Exception("coefficient 'A' cannot be 0") coeffB = int(input('Enter the coefficient B: ')) coeffC = int(input('Enter the coefficient C: ')) disc = Disc.discriminant(coeffA, coeffB, coeffC) if disc > 0: sol1 = (-coeffB - math.sqrt(disc)) / (2 * coeffA) sol2 = (-coeffB + math.sqrt(disc)) / (2 * coeffA) print("\nEquations has two real roots. " '\nx1 = ', format(sol1, '.2f'), '\nx2 = ', format(sol2, '.2f')) elif disc == 0: sol1 = -coeffB / (2 * coeffA) print('\nThe equation has one real root.' '\nx1 = ', format(sol1, '.2f')) else: print("\nNo real roots") print('\nThe discriminant is: ', format(disc, '.2f'))
def BeforeFinish(self): Disc.writeContentToDisc("Nombre: " + self.nombreContacto + ". Numero: " + str(self.numero) + "\n", "contactos")
def userInput(): coeffA = int(input('Enter the coefficient A: ')) coeffB = int(input('Enter the coefficient B: ')) coeffC = int(input('Enter the coefficient B: ')) disc = Disc.discriminant(coeffA, coeffB, coeffC) solution(coeffA,coeffB,coeffC,disc)
def set_disc(self, color): self.disc = Disc(color)
def adding_disc_into_list(): """ Adds a disc to the list of discs. """ discs.append(Disc())