+ 1
a program which will allow people to drink beer based on their age and gender. .but i am not able to associate the gender part
how t assign that character value of male (m) and female (f) ..so that it would be able to decide based on age and gender? ????
4 Respostas
+ 5
a = int(input("age?"))
g = input("gender? (m/f)")
if a >= 19 and g == "f":
print("OK you can have a beer.")
if a < 19:
print("Sorry, you're too young to drink beer.")
if g == "m":
print("Sorry, males are not allowed to drink beer ;)")
+ 5
The first 'If' is the simultaneous use of 2 conditionals. The second and third aren't really necessary for the algorithm - they just explain to the users why they can't have a beer.
0
You can just define what is the minimum age for (m) and (f) based on that you can decide whether he or she is allowed to drink beer.
0
if you want to use both age and gender simultaneously by conditional operation. .then???