Effective Testing

Effective Testing

Share

Testing services, consulting, test teams available in multiple technologies. Test automation for web, mobile, desktop applications.

Test automation with frontend and backend. Model-based testing solutions.

27/12/2025

βœ… Solution β€” Python Intermediate Task (Part 2)

Here’s a clean, Pythonic solution using filtering and lambda expressions:

def above_average(numbers):
avg = sum(numbers) / len(numbers)
return list(filter(lambda x: x > avg, numbers))

numbers = [3, 10, 7, 14, 1, 9, 20]
print(above_average(numbers))

πŸ”Ž Why this works

Average is calculated once

filter() expresses intent clearly

lambda keeps logic inline

πŸ’‘ Alternative solutions using list comprehensions are equally valid.

27/12/2025

βœ… Solution β€” Python Intermediate Task (Part 1)

Here’s a more advanced and functional-style solution using dictionary comprehension:

def count_words(words):
return {word: words.count(word) for word in set(words)}

words = ["apple", "banana", "apple", "orange", "banana", "apple"]
print(count_words(words))

πŸ”Ž Why this works

set(words) removes duplicates

words.count() maps each word to its frequency

Dictionary comprehension keeps the solution concise

⚠️ Note: This is elegant, but not optimal for very large lists β€” a good interview discussion point.

27/12/2025

🐍 Python Intermediate Task (Part 2)

This task focuses on mapping, filtering, and numerical logic.

πŸ” Task

You are given a list of numbers.

Your task is to:

Calculate the average of the list

Return a new list containing only numbers greater than the average

Assume the list is not empty.

πŸ“₯ Example Input
numbers = [3, 10, 7, 14, 1, 9, 20]

πŸ“€ Expected Output
[10, 14, 20]

🧠 Challenge

Write a function that:

Uses functional or declarative style

Minimizes temporary variables

Is readable and efficient

πŸ”₯ Bonus: Solve it in a single expression.

27/12/2025

🐍Python Intermediate Task (Part 1)

This task focuses on data aggregation, dictionaries, and Pythonic thinking.

πŸ” Task

You are given a list of strings.

Your task is to:

Count how many times each string appears

Return the result as a dictionary

Keys = words, Values = frequency

πŸ“₯ Example Input
words = ["apple", "banana", "apple", "orange", "banana", "apple"]

πŸ“€ Expected Output
{"apple": 3, "banana": 2, "orange": 1}

🧠 Challenge

Implement a function that:

Solves the task in a Pythonic way

Avoids explicit for loops if possible

Does NOT use collections.Counter

πŸ’¬ Share your approach or code in the comments.

Want your business to be the top-listed Furniture Store in London?
Click here to claim your Sponsored Listing.

Address

London