Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to check if a is less than b.
Rust
let a = 5; let b = 10; 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 check the opposite condition.
โ Incorrect
The operator < checks if the left value is less than the right value.
2fill in blank
mediumComplete the code to check if x is equal to y.
Rust
let x = 7; let y = 7; let is_equal = x [1] y; println!("{}", is_equal);
Drag options to blanks, or click blank then click option'
Attempts:
3 left
๐ก Hint
Common Mistakes
Using = instead of == assigns a value instead of comparing.
โ Incorrect
The operator == checks if two values are equal.
3fill in blank
hardFix the error in the code to check if num is not equal to 0.
Rust
let num = 3; let check = num [1] 0; println!("{}", check);
Drag options to blanks, or click blank then click option'
Attempts:
3 left
๐ก Hint
Common Mistakes
Using == will check for equality, not inequality.
โ Incorrect
The operator != checks if two values are not equal.
4fill in blank
hardFill the blank to create a dictionary with words as keys and their lengths as values, only for words longer than 3 letters.
Rust
let words = ["apple", "cat", "banana", "dog"]; let lengths = words.iter().filter(|&&word| word.len() [1] 3).map(|&word| (word, word.len())).collect::<std::collections::HashMap<_, _>>();
Drag options to blanks, or click blank then click option'
Attempts:
3 left
๐ก Hint
Common Mistakes
Using < will select shorter words instead.
โ Incorrect
The operator > filters words with length greater than 3.
5fill in blank
hardFill the blanks to create a HashMap with uppercase keys and values greater than 2.
Rust
let data = vec![("one", 1), ("two", 2), ("three", 3)]; let filtered: std::collections::HashMap<_, _> = data.into_iter() .filter(|&(_, v)| v [1] 2) .map(|(k, v)| (k.[2](), v)) .collect();
Drag options to blanks, or click blank then click option'
Attempts:
3 left
๐ก Hint
Common Mistakes
Using < will filter wrong values.
Using to_lowercase will not convert keys to uppercase.
โ Incorrect
The operator > filters values greater than 2, and to_uppercase converts keys to uppercase.