Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to check if both conditions are true.
Rust
let a = true; let b = false; let result = a [1] b; println!("{}", result);
Drag options to blanks, or click blank then click option'
Attempts:
3 left
๐ก Hint
Common Mistakes
Using || instead of && will return true if either is true.
โ Incorrect
The && operator returns true only if both a and b are true.
2fill in blank
mediumComplete the code to check if either condition is true.
Rust
let x = false; let y = true; let result = x [1] y; println!("{}", result);
Drag options to blanks, or click blank then click option'
Attempts:
3 left
๐ก Hint
Common Mistakes
Using && instead of || will require both to be true.
โ Incorrect
The || operator returns true if at least one of x or y is true.
3fill in blank
hardFix the error in the code to correctly negate the boolean value.
Rust
let flag = true; let negated = [1]flag; println!("{}", negated);
Drag options to blanks, or click blank then click option'
Attempts:
3 left
๐ก Hint
Common Mistakes
Using ~ or not which are not valid boolean negation in Rust.
โ Incorrect
The ! operator negates a boolean value in Rust.
4fill in blank
hardFill both blanks to create a condition that is true only if a is true and b is false.
Rust
let a = true; let b = false; if a [1] [2] b { println!("Condition met"); }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
๐ก Hint
Common Mistakes
Using || instead of && will allow b to be true.
โ Incorrect
The condition uses && to require both parts true, and ! to negate b.
5fill in blank
hardFill all three blanks to create a condition that is true if either x is false or y is true and z is true.
Rust
let x = true; let y = false; let z = false; if [1] x [2] y [3] z { println!("Complex condition met"); }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
๐ก Hint
Common Mistakes
Mixing up operator precedence or forgetting to negate x.
โ Incorrect
The condition reads: if !x || y && z, which means true if x is false or both y and z are true.