# challenges

difficulty: easy
date_created: 2025-07-23 21:01:53.514832
created_by: user_30DHYZM1kXPaOMyDrozEo5bAETz
title: What is the output of the following Python code? x = 5 y = 2 print(x + y * 3)
options: ["11", "17", "21", "23"]
explanation:
The correct answer is 17. In Python, as in most programming languages, multiplication has higher precedence than addition. So, the expression is evaluated as:

1. First, y * 3 is calculated: 2 * 3 = 6
2. Then, x is added to the result: 5 + 6 = 11

Therefore, the final output is 17.

This question tests the understanding of basic arithmetic operations and operator precedence in Python. It's a common mistake for beginners to assume that operations are always performed from left to right, which would incorrectly lead to the answer 21 (5 + 2 = 7, then 7 * 3 = 21).

Remember, if you want to force the addition to happen first, you would need to use parentheses, like this: (x + y) * 3, which would indeed give 21 as the result.


difficulty: easy
date_created: 2025-07-23 21:03:56.070960
created_by: user_30DHYZM1kXPaOMyDrozEo5bAETz
title: What is the output of the following Python code? x = 5 y = 2 print(x + y * 3)
options: ["11", "17", "21", "Error"]
explanation:
The correct answer is 11. In Python, like in most programming languages, multiplication has higher precedence than addition. So, the expression is evaluated as:

1. First, y * 3 is calculated: 2 * 3 = 6
2. Then, x is added to the result: 5 + 6 = 11

It's important to note that Python follows the standard order of operations (PEMDAS - Parentheses, Exponents, Multiplication/Division, Addition/Subtraction). If we wanted to add x and y first, we would need to use parentheses like this: (x + y) * 3, which would give a different result of 21.

This question tests basic understanding of arithmetic operations and operator precedence in Python, which is why it's suitable for an easy difficulty level.


difficulty: medium
date_created: 2025-07-23 21:37:51.407487
created_by: user_30DHYZM1kXPaOMyDrozEo5bAETz
title: Find the Missing Number in a Sequence
options: ["O(n)", "O(n log n)", "O(1)", "O(n^2)"]
explanation:
The correct answer is O(1), which represents constant time complexity. This is because we can use a mathematical formula to find the missing number in a sequence from 1 to n in constant time, regardless of the size of the input.

The formula to find the sum of numbers from 1 to n is: n * (n + 1) / 2

We can use this formula to calculate the expected sum of all numbers from 1 to n, and then subtract the actual sum of the given sequence. The difference will be the missing number.

Here's how the algorithm works:
1. Calculate the expected sum using the formula: n * (n + 1) / 2
2. Calculate the actual sum of the given sequence
3. Subtract the actual sum from the expected sum

This process takes a constant number of operations, regardless of the size of the input sequence. Therefore, the time complexity is O(1).

The other options are incorrect:
- O(n): This would be the time complexity if we had to iterate through the entire sequence once.
- O(n log n): This is typically the time complexity for efficient sorting algorithms, which is not necessary for this problem.
- O(n^2): This would be the time complexity for nested loops, which are not needed to solve this problem efficiently.


difficulty: easy
date_created: 2025-07-23 21:38:23.762322
created_by: user_30DHYZM1kXPaOMyDrozEo5bAETz
title: What is the output of the following Python code? x = 5 y = 2 print(x + y * 3)
options: ["11", "17", "21", "Error"]
explanation:
The correct answer is 17. In Python, like in most programming languages, multiplication has higher precedence than addition. So, the expression is evaluated as:

1. First, y * 3 is calculated: 2 * 3 = 6
2. Then, x is added to the result: 5 + 6 = 11

Therefore, the final output is 17.

This question tests the understanding of basic arithmetic operations and operator precedence in Python, which is an important concept for beginners to grasp. It's a common mistake for new programmers to assume that operations are always performed from left to right, which would incorrectly lead to the answer 21 ((5 + 2) * 3).


difficulty: easy
date_created: 2025-07-23 21:55:37.276601
created_by: user_30DHYZM1kXPaOMyDrozEo5bAETz
title: What is the output of the following Python code? x = 5 y = 2 print(x + y * 3)
options: ["11", "17", "21", "Error"]
explanation:
The correct answer is 17. In Python, like in most programming languages, multiplication (*) has higher precedence than addition (+). This means that y * 3 is evaluated first, which equals 2 * 3 = 6. Then, this result is added to x, so we have 5 + 6 = 11. 

The order of operations is as follows:
1. y * 3 = 2 * 3 = 6
2. x + 6 = 5 + 6 = 11

Therefore, the final output of the print statement is 17.

This question tests basic understanding of arithmetic operations and operator precedence in Python, which is why it's suitable for an easy difficulty level. It's a common mistake for beginners to assume that operations are always performed from left to right, which would incorrectly lead to the answer 21 ((5 + 2) * 3).


