17.4k views
4 votes
Which of the following statements tests if users walked 10,000 or more steps and ate fewer than 25 grams of sugar?

A. if(steps >= 10,000 and sugar > 25);
B. if(steps >= 10,000 or sugar < 25):
C. if(steps >= 10,000 and sugar < 25):
D. if(steps > 10,000 or sugar < 25):

User Wrozwad
by
5.0k points

2 Answers

1 vote

Answer:

C. if(steps >= 10,000 and sugar < 25):

Step-by-step explanation:

This makes it so the if statement not only needs to have both sides of the and statement true, but has both sides correct, as the user walked exactly or more then 10,000 steps, and has eaten more than 25 grams, not exactly 25 grams of sugar.

User Masoom Badi
by
4.4k points
1 vote

Answer:

C. if(steps >= 10,000 and sugar < 25):

Step-by-step explanation:

This is a combined statement, where by two different conditions are being evaluated. The statement only returns TRUE; if each of the two conditions are TRUE.

The sign '>=' means greater than or equal in computer programming.

Hence, steps >= 10000 (step is 10000 or more)

< less than

Sugar < 25 (sugar is below of fewer Than 25)

and : requires that the two conditions comes up true for any data passed in.

User Jurgy
by
4.0k points