Python
Python
import random
from typing import List, Dict, Any, Tuple

# John's profile and job_opportunities remain the same as in the previous
# version
john = {
    'name': 'John',
    'skills': {
        'Python': 7,
        'JavaScript': 6,
        'Machine Learning': 4,
        'Data Analysis': 5,
        'Web Development': 6
    },
    'experience': 2,  # years
    'education': "Bachelor's in Computer Science",
    'interests': ['AI', 'Web Development', 'Data Science'],
    'preferred_work_style': 'hybrid',
    'career_goals': ['full-stack developer', 'AI specialist']
}

# Sample job opportunities
job_opportunities = [
    {
        'title': 'Junior Full Stack Developer',
        'required_skills': {
            'Python': 5,
            'JavaScript': 6,
            'Web Development': 7
        },
        'preferred_skills': {
            'React': 4,
            'Node.js': 4
        },
        'min_experience': 1,
        'education': "Bachelor's in Computer Science or related field",
        'work_style': 'hybrid',
        'career_track': 'full-stack developer'
    },
    {
        'title': 'Machine Learning Engineer Intern',
        'required_skills': {
            'Python': 6,
            'Machine Learning': 5,
            'Data Analysis': 5
        },
        'preferred_skills': {
            'TensorFlow': 3,
            'PyTorch': 3
        },
        'min_experience': 0,
        'education': "Bachelor's or Master's in Computer Science, focus on AI/ML",
        'work_style': 'onsite',
        'career_track': 'AI specialist'
    },
    {
        'title': 'Data Scientist',
        'required_skills': {
            'Python': 7,
            'Data Analysis': 8,
            'Machine Learning': 6
        },
        'preferred_skills': {
            'SQL': 5,
            'Data Visualization': 6
        },
        'min_experience': 3,
        'education': "Master's in Data Science or related field",
        'work_style': 'remote',
        'career_track': 'data scientist'
    }
]

def calculate_job_match_score(candidate: Dict[str, Any], job: Dict[str, Any]) -> Tuple[float, Dict[str, Any]]:
    score = 0
    max_score = 100
    feedback = {}

    # Skills match (0-40 points)
    skills_score = 0
    for skill, required_level in job['required_skills'].items():
        if skill in candidate['skills']:
            skills_score += min(10, (candidate['skills'][skill] / required_level) * 10)
    for skill, preferred_level in job.get('preferred_skills', {}).items():
        if skill in candidate['skills']:
            skills_score += min(5, (candidate['skills'][skill] / preferred_level) * 5)
    skills_score = min(40, skills_score)
    score += skills_score
    feedback['skills_match'] = f"{skills_score:.1f}/40"

    # Experience match (0-15 points)
    if job['min_experience'] == 0:
        experience_score = 15  # Full points if no experience required
    elif candidate['experience'] >= job['min_experience']:
        experience_score = min(15, 10 + (candidate['experience'] - job['min_experience']))
    else:
        experience_score = (candidate['experience'] / job['min_experience']) * 15
    score += experience_score
    feedback['experience_match'] = f"{experience_score:.1f}/15"

    # Education match (0-10 points)
    if job['education'].lower() in candidate['education'].lower():
        score += 10
        feedback['education_match'] = "10/10"
    else:
        feedback['education_match'] = "0/10"

    # Interest and career goal alignment (0-20 points)
    interest_score = 0
    if job['career_track'] in candidate['career_goals']:
        interest_score += 10
    if any(interest.lower() in job['title'].lower() for interest in candidate['interests']):
        interest_score += 10
    score += interest_score
    feedback['interest_alignment'] = f"{interest_score:.1f}/20"

    # Work style match (0-15 points)
    if job['work_style'] == candidate['preferred_work_style']:
        score += 15
        feedback['work_style_match'] = "15/15"
    else:
        feedback['work_style_match'] = "0/15"

    # Normalize score
    final_score = (score / max_score) * 100

    return final_score, feedback

def match_jobs(candidate: Dict[str, Any], jobs: List[Dict[str, Any]]) -> List[Tuple[Dict[str, Any], float, Dict[str, Any]]]:
    job_matches = []
    for job in jobs:
        score, feedback = calculate_job_match_score(candidate, job)
        job_matches.append((job, score, feedback))
    
    # Sort jobs by score in descending order
    job_matches.sort(key=lambda x: x[1], reverse=True)
    return job_matches

# Run the job matching algorithm
matches = match_jobs(john, job_opportunities)

# Output results
print("Job Recommendations for John:")
for i, (job, score, feedback) in enumerate(matches, 1):
    print(f"\nRecommendation {i}: {job['title']}")
    print(f"Match Score: {score:.2f}%")
    print("\nJob Details:")
    print(f"  Required Skills: {', '.join(job['required_skills'].keys())}")
    print(f"  Preferred Skills: {', '.join(job.get('preferred_skills', {}).keys())}")
    print(f"  Minimum Experience: {job['min_experience']} years")
    print(f"  Education: {job['education']}")
    print(f"  Work Style: {job['work_style']}")
    print(f"  Career Track: {job['career_track']}")
    
    print("\nMatch Analysis:")
    print(f"  Skills Match: {feedback['skills_match']}")
    print(f"  Experience Match: {feedback['experience_match']}")
    print(f"  Education Match: {feedback['education_match']}")
    print(f"  Interest Alignment: {feedback['interest_alignment']}")
    print(f"  Work Style Match: {feedback['work_style_match']}")

    print("\nStrengths:")
    strengths = [k for k, v in feedback.items() if float(v.split('/')[0]) / float(v.split('/')[1]) > 0.7]
    for strength in strengths:
        print(f"  - {strength.replace('_', ' ').title()}")

    print("\nAreas for Improvement:")
    improvements = [k for k, v in feedback.items() if float(v.split('/')[0]) / float(v.split('/')[1]) <= 0.7]
    for improvement in improvements:
        print(f"  - {improvement.replace('_', ' ').title()}")

print("\nOverall Recommendation:")
if matches[0][1] > 80:
    print(f"The {matches[0][0]['title']} position is an excellent match for John's skills and career goals.")
elif matches[0][1] > 60:
    print(f"The {matches[0][0]['title']} position is a good match, but John might need to improve in some areas.")
else:
    print("John might want to consider upskilling or exploring different roles that better align with his current skills and interests.")
Job Recommendations for John:

Recommendation 1: Junior Full Stack Developer
Match Score: 64.57%

Job Details:
  Required Skills: Python, JavaScript, Web Development
  Preferred Skills: React, Node.js
  Minimum Experience: 1 years
  Education: Bachelor's in Computer Science or related field
  Work Style: hybrid
  Career Track: full-stack developer

Match Analysis:
  Skills Match: 28.6/40
  Experience Match: 11.0/15
  Education Match: 0/10
  Interest Alignment: 10.0/20
  Work Style Match: 15/15

Strengths:
  - Skills Match
  - Experience Match
  - Work Style Match

Areas for Improvement:
  - Education Match
  - Interest Alignment

Recommendation 2: Machine Learning Engineer Intern
Match Score: 53.00%

Job Details:
  Required Skills: Python, Machine Learning, Data Analysis
  Preferred Skills: TensorFlow, PyTorch
  Minimum Experience: 0 years
  Education: Bachelor's or Master's in Computer Science, focus on AI/ML
  Work Style: onsite
  Career Track: AI specialist

Match Analysis:
  Skills Match: 28.0/40
  Experience Match: 15.0/15
  Education Match: 0/10
  Interest Alignment: 10.0/20
  Work Style Match: 0/15

Strengths:
  - Experience Match

Areas for Improvement:
  - Skills Match
  - Education Match
  - Interest Alignment
  - Work Style Match

Recommendation 3: Data Scientist
Match Score: 32.92%

Job Details:
  Required Skills: Python, Data Analysis, Machine Learning
  Preferred Skills: SQL, Data Visualization
  Minimum Experience: 3 years
  Education: Master's in Data Science or related field
  Work Style: remote
  Career Track: data scientist

Match Analysis:
  Skills Match: 22.9/40
  Experience Match: 10.0/15
  Education Match: 0/10
  Interest Alignment: 0.0/20
  Work Style Match: 0/15

Strengths:

Areas for Improvement:
  - Skills Match
  - Experience Match
  - Education Match
  - Interest Alignment
  - Work Style Match

Overall Recommendation:
The Junior Full Stack Developer position is a good match, but John might need to improve in some areas.