78. Count User Events from JSON Activity Logs
Beginner Mode
Start your terminal to use beginner mode.
Scenario
A JSON file contains user activity logs with various events. You need to analyze the logs and generate a report showing how many events each user performed.
Task
Write a Python script at /home/interview/count_events.py that reads /home/interview/activity_logs.json, counts the number of events per user, and saves the results as a JSON file to /home/interview/user_event_counts.json.
Example
Expected output format in /home/interview/user_event_counts.json:
{
"user_123": 5,
"user_456": 12,
"user_789": 3
}
Terminal requires a larger screen
Open this page on a desktop or tablet (≥ 768px) to launch the terminal and practice hands-on.
Linux Terminal Environment
Write and execute your solution in the terminal below.
Essential
SQL 0/33
Spark 0/20
Snowflake 0/22
Python 0/24
Need more practice in this area? Explore more questions →
Uber
Revolut
Accenture
Adobe
Google
LinkedIn
Samsung
Datadog
Wix
Dropbox
Meta
OpenAI
Hulu
X
DoorDash
Anthropic
Amazon
ActivisionBlizzard
Vercel
Crypto.Com
Zscaler
DeutscheBank
Apple
GoDaddy
GitLab
BMW
PayPal
Snowflake
AMD
Twilio
Atlassian
JPMorgan
NVIDIA
IBM
Databricks
Coinbase
Cisco
Robinhood
Twitter
Microsoft
Palantir
Netflix
VMware
Cloudflare
Stripe
Lyft
Salesforce
GitHub
Bloomberg
Airbnb
Walmart
SAP
HashiCorp
Instacart
Mastercard
Intel
Visa
Tesla