thecodingcompany
Programming

Python coding practice

The default language for AI and data roles, and the most common first coding round.

Exercises6
FormatPrompt + hint

6 exercises

Try each one before reading the hint. If you finish without using the hint, move on; if the hint is not enough, work the neighbouring DSA pattern.

01Reverse a string without slicing
TaskWrite a function that reverses a string using a loop, without using s[::-1] or reversed().
HintBuild a new string by prepending each character, or iterate from the last index down to 0.
02Check for a palindrome
TaskReturn True if a string reads the same forwards and backwards, ignoring case and non-alphanumeric characters.
HintNormalise with a comprehension that keeps only alphanumerics and lowercases, then compare to its reverse.
03Count word frequency
TaskGiven a sentence, return a dictionary of each word and how many times it appears.
HintUse .split() and dict.get(word, 0) + 1 in a loop.
04Find the second largest number
TaskReturn the second largest distinct value in a list, in a single pass if possible.
HintTrack the largest and second largest as you iterate; handle duplicates by requiring the value to be strictly less than the largest.
05FizzBuzz variant
TaskPrint numbers 1 to n, but print "Fizz" for multiples of 3, "Buzz" for 5, and "FizzBuzz" for both.
HintCheck divisibility by 15 first, or concatenate the words and fall back to the number.
06Merge two sorted lists
TaskGiven two sorted lists, merge them into one sorted list without using sorted() or sort().
HintTwo pointers, one per list; append whichever current value is smaller, then drain the rest.

Practise here. Get placed there.

Prep+ is unlimited practice. When you are ready to turn it into an offer, TCC Placement Partner handles portfolio, resume and interviews.