All questions of Introduction to Python 3.11 for Class 9 Exam
The first `print (x / y)` outputs `3.5`.
The second `print(x // y)` outputs `3` (integer division).
The third `print(x % y)` outputs `1` (remainder).
The fourth `print(y ** x)` outputs `49` (power calculation).
`a % b` calculates the remainder of `10` divided by `3`, which is `1`.
The function `greet("Alice") `prints ` "Hello, Alice!" `.
'nums[1:3]' extracts elements from index '1' to '2' (exclusive of index '3'), so it prints '[2, 3]'.
'factorial(4)' computes '4 * 3 * 2 * 1' which equals '24'.
The condition 'x > 5' evaluates to 'True', so it prints ' "Hello, " ' followed by ' "Goodbye!" '.
`nums[2:]` slices the list from index `2` to the end, so it prints `[3, 4, 5]`.
The function 'greet("Alice")' prints ' "Hello, Alice!" '.
The loop iterates through numbers from '1' to '4'. It prints even numbers ('2' and '4') due to the 'if i % 2 == 0' condition.
`factorial(5)` computes `5 * 4 * 3 * 2 * 1` which equals `120`.
`nums[::-1]` reverses the list `nums`, so it prints `[5, 4, 3, 2, 1]`.
- `x & y` performs bitwise AND (`0101 & 0011`), resulting in `0001` which is `1`.
- `x | y` performs bitwise OR (`0101 | 0011`), resulting in `1000` which is `8`.
- `x ^ y` performs bitwise XOR (`0101 ^ 0011`), resulting in `0110` which is `6`.
The function `greet()` returns ` "Hello, World!" ` which is then printed.
`x // y` performs integer division of `8` by `2`, resulting in `4`.
The function `greet()` returns ` "Hello, World!" `which is then printed.
- The first 'print(x / y)' outputs '2.5'.
- The second 'print(x // y)' outputs '2' (integer division).
- The third 'print(x % y)' outputs '1' (remainder).
- The fourth 'print(y ** x)' outputs '32' (power calculation).
`x ** y` calculates `5` raised to the power `2`, resulting in `25`.
- `x & y` performs bitwise AND (`0110 & 0011`), resulting in `0010` which is `2`.
- `x | y` performs bitwise OR (`0110 | 0011`), resulting in `0111` which is `7`.
- `x ^ y` performs bitwise XOR (`0110 ^ 0011`), resulting in `0101` which is `5`.
`nums[::-1]` reverses the list `nums`, so it prints `[5, 4, 3, 2, 1]`.
The `range(1, 6, 2)` generates numbers `1, 3, 5`. The loop prints these numbers with a space in between.