What is the output of the following Python code snippet? a = 17 b = 5 print(a // b, a % b)
Algoritmicke Riesenie Problemov
Question · Easy
New hire access: Expectation vs Reality
Short
Consider the following sequence of variable assignments in Python: x = 10 x += 6 x *= 2 x //= 4 What is the final value of variable x?
What is the truth value of the following Boolean expression in Python? not (5 > 3) or (10 == 2 * 5 and not False)
According to De Morgan's laws, which of the following expressions is logically equivalent to the negated condition `not (x >= 5 and y < 10)`?
Question · Medium
What is the output of the following Python loop? total = 0 for i in range(1, 10, 2): total += i print(total)
What value of count is printed by this nested loop? count = 0 for i in range(4): for j in range(i, 4): count += 1 print(count)
What is printed by the following Python program featuring break and continue? s = 0 for n in range(1, 8): if n % 2 == 0: continue if n > 5: break s += n print(s)
Question · Hard
What will be printed when the following while loop finishes execution? x = 1 while x < 15: x *= 2 print(x)
Examine this algorithm intended to find how many times an integer `n` can be divided by 2 before becoming less than or equal to 1: n = 40 count = 0 while n > 1: n = n // 2 count += 1 print(count) What is the value of `count` printed?
What is the output of the following Python program containing a custom function? def compute(a, b=3): return (a + 2) * b result = compute(4) print(result)
What is printed by the following code demonstrating variable scope in Python? x = 5 def modify(): global x x = 20 y = 10 modify() print(x)
Which sequence of statements correctly swaps the values of variables a and b using a helper variable t?
What does the following program print? n = 4096 s = 0 while n > 0: s += n % 10 n //= 10 print(s)
What does the following program print? text = 'Bratislava 2026' count = 0 for ch in text: if ch.isdigit(): count += 1 print(count)
Given the Python list `nums = [10, 25, 30, 45, 50]`, what value is returned by `nums[-2]`?
Consider the following algorithm for finding the maximum element in a non-empty list of integers `arr`: m = arr[0] for i in range(1, len(arr)): if arr[i] > m: m = arr[i] Why is initializing `m = arr[0]` preferred over initializing `m = 0`?
Which code snippet correctly reverses an array `arr` of length `n` in place without creating a new array?
What is the output of the following code summing elements of a 3x3 matrix? m = [ [1, 2, 3], [4, 5, 6], [7, 8, 9] ] s = 0 for i in range(len(m)): s += m[i][i] print(s)
Given an n x n square matrix `A`, which nested loop structure correctly computes the sum of all elements strictly above the main diagonal?
What is the output of the following Python string slicing expression? s = 'INFORMATIKA' print(s[2:7])
Which of the following functions correctly determines whether a string `w` is a palindrome (reads identically forwards and backwards), ignoring case?
When linear search looks for a value in an unsorted list of n elements, what are the smallest and the largest possible numbers of comparisons?
Examine this linear search function: def find_first(arr, target): for i in range(len(arr)): if arr[i] == target: return i return -1 What does returning -1 signify?
What essential precondition must be satisfied before binary search can be applied to an array?
Binary search is executed to find target value 38 in the sorted list: `arr = [3, 9, 14, 21, 28, 38, 45, 52, 60]` with `mid = (low + high) // 2`. Which sequence of middle element values is checked?
If an array contains 1,000,000 sorted elements, approximately what is the maximum number of comparisons binary search requires to find a key or determine it is absent?
A program simulates throwing two dice with s = random.randint(1, 6) + random.randint(1, 6). Which statement about the possible values of s is correct?
What does the following program print? count = 0 with open('data.txt') as f: for line in f: count += 1 print(count)
A program reads whole numbers from the keyboard until the user enters 0, and the number of values is not known in advance. Which construct is the most suitable?
What does the following program print? freq = [0] * 5 for x in [1, 3, 3, 4, 1, 3]: freq[x] += 1 print(freq)
A program computes an average with avg = total / count, where count is the number of values entered. Which test input is most likely to reveal a critical error?
A program inserts the value 4 into the sorted list [2, 5, 7, 9] (stored with one free slot at the end) by shifting larger elements one position to the right. How many elements must be shifted?
Two sorted lists a = [2, 5, 8] and b = [3, 4, 9] are merged into one sorted list by repeatedly comparing the first unused element of each list and appending the smaller one. Which value is appended in the fourth step?
How many asterisks does the following program print in total? n = 5 for i in range(1, n + 1): print('*' * i)
A student writes a program to calculate the average of 5 exam grades. The program runs without any error message, but outputs 13.6 when the true average is 3.2. What type of error occurred?
What is the decimal (base-10) equivalent of the binary number 110101_2?
Reprezentacie A Nastroje
What is the binary representation of the decimal number 77_10?
What is the decimal value of the hexadecimal number 2F_16?
Convert the hexadecimal number A5C_16 directly into binary by translating each hex digit into a 4-bit nibble.
Which binary sequence represents the octal number 57_8 by grouping into 3-bit triads?
An 8-bit unsigned integer register performs binary addition of 11001000_2 (200_10) and 01100100_2 (100_10). What decimal value remains in the 8-bit register, and what hardware event occurs?
How is the negative decimal integer -42 represented in an 8-bit two's complement (dvojkový doplnok) format?
What decimal value is represented by the 8-bit two's complement byte `11110110_2`?
What is the exact range of signed integers that can be represented in an n-bit two's complement format?
How long does it take to download a 25 MB file over a connection with a transfer rate of 50 Mb/s, ignoring protocol overhead? (Use 1 B = 8 b and 1 MB = 1,000,000 B.)
In Python, evaluating `0.1 + 0.2 == 0.3` returns False. Why does this occur in computer systems using IEEE 754 floating-point arithmetic?
How many distinct characters can be represented by the original standard ASCII encoding standard?
Loading more…