easyPythoncollections
What will this output?
a = {1, 2, 3}
b = {3, 4}
print(a ^ b)Read the full question →Easy questions check that the basics are actually automatic: syntax, defaults, and the behaviour you rely on without thinking.
Good for a first pass through a new language, or a warm-up the morning of an interview.
Expect single-concept snippets: one operator, one method, one default. If an easy question catches you out, that is the gap worth closing first.
Eighteen real easy questions from across the library, code snippet included. The answer options and explanations come after you attempt them.
a = {1, 2, 3}
b = {3, 4}
print(a ^ b)Read the full question →let arr = ["a", "b", "c"];
arr.reverse();
console.log(arr);Read the full question →let arr = ["a", "b"];
arr.push("c");
console.log(arr);Read the full question →<input type="password" name="pass">Read the full question →typeof null === "object"Read the full question →let arr = [[1, 2], [3, 4, 5]];
console.log(arr.flat());Read the full question →x = [i**2 for i in range(3)]
print(x)Read the full question →<button type="button">Click Me</button>Read the full question →const obj = {
name: "Hello",
sayHello: function() {
console.log(this.name);
}
};
obj.sayHello();Read the full question →from enum import Enum, auto
class Color(Enum):
RED = auto()
BLUE = auto()
print(Color.RED.value, Color.BLUE.value)Read the full question →let str = "Hello World";
console.log(str.toUpperCase());Read the full question →let numbers = [1, 2, 3, 4];
let result = numbers.find(n => n > 1);
console.log(result);Read the full question →let fruits = ["apple", "banana", "orange"];
console.log(fruits.indexOf("banana"));Read the full question →let add = (x, y) => x + y;
console.log(add(5, 10));Read the full question →<p>This is <em>emphasized</em> text.</p>Read the full question →<p>This is <b>bold</b> text.</p>Read the full question →<ul>\n <li>Item 1</li>\n <li>Item 2</li>\n</ul>Read the full question →let numbers = [1, 2, 3, 4];
let sum = numbers.reduce((acc, val) => acc + val);
console.log(sum);Read the full question →