0
Hello I would like to get help to a question I haven’t found answer, I have 2 loops while being ignored without any explanation (it doesn’t give error simply it passes to the next), the user must enter a float value of hours within a period of 0 to 24 hours and enter an integer value in days between 1 to 31 however conditions are being ignored (I have already commented the part above this loop however it is still ignored, in addition to what I looked for the condition is correct), the first loop related to power of an appliance is correct and is working but the other 2 not.
#while (potenciaDoArCondicionado <= 0): # Impossibilita da potência ser negativa ou 0
#potenciaDoArCondicionado = int(input("Qual a potência desse Ar-condicionado? "))
#potenciaDoArCondicionado = (potenciaDoArCondicionado/1000) #Fórmula que faz a conversão de Watts para Quilowatt
horasDoArCondicionado = 0 # Essa variável guarda quantas horas se utiliza o Ar Condicionado
while(horasDoArCondicionado<=0 and horasDoArCondicionado>24):
horasDoArCondicionado = float(input("Quantas horas por dia se utiliza este Ar-condicionado desse setor? "))
diasDoArCondicionado = 0 # Essa variável guarda quantos dias no mês se utiliza o Ar Condicionado
while(diasDoArCondicionado<1 and diasDoArCondicionado>31):
diasDoArCondicionado = int(input("Quantas dias no mês se utiliza o Ar-condicionado desse setor? "))
How can something be "less/equal to zero And greater than 24" at the same time? Same thing for the date, how can a day be "less than a And greater than 31"? Give me an example of value that meets any of these situations you used. Obviously they are conditions that will always be false, so it does not meet the requirement for while to occur.
– Bacco
Then it would be right?
– Alexandre Caribé
"AND" means "E" (as long as it is less than one E greater than thirty-one repeat the question), "OR" means "OR" (as long as it is less than one OR greater than thirty-one repeat the question). Which one correctly represents your intention?
– Bacco
I need the user to enter a value greater than 0 in hours (because later I will use this value for a consumption calculation) and that this value does not exceed 24 hours. The same for days, must be longer than 1 day and not exceed 31 days
– Alexandre Caribé
And which of the two sentences I said represents what you just said? Beware that you stated what you need, but in the loop you are dealing with what "does not need" (ie, repeat the question while the value is unsatisfactory)
– Bacco
From what I have learned so far for my two conditions to be met it would be E (and), because the OR (or) only needs one correct condition for it to give True. (I ended up noticing something in this code I ended up putting one of the signals of the wrong bottom condition because it would have to be bigger than 1 and not smaller than 1)
– Alexandre Caribé
With your last comment in mind, reread your question and especially your code. It makes sense for you to perform a repeat loop while the number is less than 0 and greater than 24?
– Woss
It really does not, I ended up getting confused a little because I was thinking with a logic similar to Digital Circuits (and, or, xor, nor, xnor, Nand not). Thanks for the help and sorry for anything. I’m in my first semester and had my first contact with the schedule now.
– Alexandre Caribé