If statement + logical and/or | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

If statement + logical and/or

Can I create the code for below scenario by using If statement + logical and/or? Output may more than 1 subjected to it fall in the group. Note: Using "," to separate the data. Sport, Age yrs, Males (VO2Max), Females (VO2Max) Basketball, 18 - 30, 40 – 60, 43 – 60 Bicycling, 18 - 26, 62 – 74, 47 – 57 Canoeing, 18 - 26, 55 – 67, 47 – 67 Gymnastics, 18 - 22, 52 – 58, 36 – 50 Swimming, 10 - 25, 50 – 70, 40 – 60

10th Jul 2018, 11:27 AM
Hong Min
Hong Min - avatar
1 Answer
0
It works like this: ( I asume the sport is a string and the numbers are the age as integer.) if 'Basketball' and (( age >= 18 and age <= 30) or (age >= 40 and age <= 60) or (age >= 43 and age <= 60)) # Do something. watch out for the '((' and the '))' that's the age part. You can replicate the code for any sports, but change the age numbers.
9th Aug 2018, 9:44 PM
Detlef
Detlef - avatar