JOB READY CHALLENGE
Can you debug this Python code? π
Youβre working on a data-processing script, but it crashes when the API returns incomplete data.
users = [
{"name": "Rahul", "age": 25},
{"name": "Priya"},
{"name": "Aman", "age": 22}
]
for user in users:
print(user["name"], user["age"])
π― Your Challenge:
Fix the code so that it prints every user's name and age without throwing an error.
Bonus: Handle missing ages by displaying "Not Available".
π‘ Interview Tip:
Don't just write code that works. Be ready to explain WHY the error occurs and HOW your solution handles missing data.
β±οΈ Time Limit: 5 minutes
π Drop your solution in the comments!
#JobReadyChallenge #TechJobs #Python #CodingChallenge #TechInterview #Programming #EdTech #HCLGUVI
Can you optimize this Python code? π
Youβre processing a list of numbers, but the code is doing more work than necessary.
numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
even_numbers = []
for num in numbers:
if num % 2 == 0:
even_numbers.append(num)
π― Your Challenge:
Rewrite this code to make it shorter and cleaner without changing the output.
π‘ Hint: Python has a built-in way to create lists more efficiently.
Bonus: Can you do it in one line?
π§ Interview Tip:
Optimization isn't always about fewer lines. Be ready to explain why your solution is cleaner and when you would use it.
β±οΈ Time Limit: 5 minutes
π Drop your optimized solution in the comments!
#JobReadyChallenge #Python #CodingChallenge #CodeOptimization #TechInterview #Programming #EdTech #HCLGUVI
Youβre processing a list of numbers, but the code is doing more work than necessary.
numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
even_numbers = []
for num in numbers:
if num % 2 == 0:
even_numbers.append(num)
π― Your Challenge:
Rewrite this code to make it shorter and cleaner without changing the output.
π‘ Hint: Python has a built-in way to create lists more efficiently.
Bonus: Can you do it in one line?
π§ Interview Tip:
Optimization isn't always about fewer lines. Be ready to explain why your solution is cleaner and when you would use it.
β±οΈ Time Limit: 5 minutes
π Drop your optimized solution in the comments!
#JobReadyChallenge #Python #CodingChallenge #CodeOptimization #TechInterview #Programming #EdTech #HCLGUVI
β€2