-3
Art. 42. Can adopt the over 18 (eighteen) years, regardless of marital status.
§ 1º Cannot adopt the ascendants and the brothers of the adopting.
§ 2º For joint adoption, it is indispensable that the adoptors are married civilly or maintain stable union, proven the stability of the family.
§ 3º The adopter must be at least sixteen years older than the one adopting him.
Art. 45. Adoption depends on the consent of the parents or the legal representative of the adopting.
§ 1. Consent will be waived in relation to the child or adolescent whose parents are unknown or have been deprived of family power.
§ 2º. In case of adopting older than twelve years of age, it will also be necessary your consent.
Write a program that captures the following information:
The Age of the Adopter
The adopter is brother or ascendant?
Is Joint Adoption?
Adopters are married or stable union?
Age of Adopting
Parents Unknown or Adopting Devoid of Family Power?
Consent of parents when not unknown?
Consent of the adopting (if older than twelve years of age)?
From the information provided, the program must inform whether or not it is possible to carry out the adoption!
I made the following code:
p1 = int(input("Digite a sua idade: "))
p2 = int(input("Digite a idade do adotando: "))
p3 = str(input("Você é irmão ou ascendente do adotando? [S/N]: "))
p4 = str(input("É adoção conjunta? [S/N]: "))
p5 = str(input("Os pais do adotando é desconhecido ou ele foi destituído do poder familiar? [S/N]: "))
if p1 < 18:
print("Você não pode adotar!!")
elif p1 - p2 < 16:
print("Você não pode adotar!!")
elif p3 == "S":
print("Você não pode adotar!!")
elif p4 == "S":
p6 = str(input("Vocês são casados ou possui união estável? [S/N]: "))
elif p6 == "N":
print("Você não pode adotar!!")
elif p5 == "N":
p7 = str(input("Os pais do adotando conscentiu a adoção? [S/N]: "))
elif p5 == "S" and p2 >= 12:
p8 = str(input("O adotando conscentiu essa adoção? [S/N]: "))
elif p7 == "N":
print("Você não pode adotar!!")
elif p8 == "N":
print("Você não pode adotar!!")
else:
print("PARABÉNS!! VOCÊ PODE ADOTAR.")
Gives the following error:
Digite a idade do adotando: 12 Você é irmão ou ascendente do adotando? [S/N]: N É adoção conjunta? [S/N]: N Os pais do adotando é desconhecido ou ele foi destituído do poder familiar? [S/N]: S --------------------------------------------------------------------------- NameError Traceback (most recent call last) <ipython-input-3-64423a1d7de4> in <module>() 12 elif p4 == "S": 13 p6 = str(input("Vocês são casados ou possui união estável? [S/N]: ")) ---> 14 elif p6 == "N": 15 print("Você não pode adotar!!") 16 elif p5 == "N": NameError: name 'p6' is not defined ```
P6 only exists if P4 is equal
S
– Bernardo Lopes
Important whenever posting something, explain objectively and punctually the difficulty found, accompanied by a [mcve] problem instead of the whole exercise (inclusive, this helps to locate the error) - the excess information is undesirable and disturbs the focus of the post. To understand what kind of question serves the site and, consequently, avoid closures and negativities worth reading What is the Stack Overflow and the Stack Overflow Survival Guide (summarized) in Portuguese.
– Bacco
Did the answer solve your question? Do you think you can accept it? See [tour] if you don’t know how you do it. This would help a lot to indicate that the solution was useful for you. You can also vote on any question or answer you find useful on the entire site (when you have 15 points).
– Maniero