Uploaded by Chiamaka Ekele

Data Science Python Assessment

advertisement
IAT DS_WEEK_1_ASSESSMENT
January 5, 2025
WEEK_1 ASSESSMENT
0.0.1
Email:
0.0.2
ID:
0.1
SECTION 1
[ ]: # 1. Declare a variable named "NAME" with your first and last name
[1]: # 2. Assign these strings to 3 variables in one line: " I'm an aspiring Data␣
↪Scientist "
[ ]: # 3. Which letter belongs to index 3 in the code below, complete the code to␣
↪print it out:
x = 'Welcome'
[ ]: #4 Define a string and convert all the letters into Uppercase
[3]: #5. If x = 9, Write the code using fstring to print 'The price is 9.00 dollars'?
[ ]: # 6. Insert orange to the list below:
mylist = ['apple', 'banana', 'cherry']
[ ]: # 7. What will be the result of the following code and why?
x = 5
x += 3
print(x)
0.2
SECTION 2
0.3
Assignment: Eligibility Checker for Health Insurance Plan
0.3.1
Problem Statement
You are tasked with creating a Health Insurance Eligibility Checker for a health insurance
company. The company wants to determine if a person qualifies for a specific health plan based on
the following criteria:
1. Age: The individual must be between 18 and 65 years old.
1
2. BMI (Body Mass Index): The BMI must be between 18.5 and 30.0.
3. Pre-existing Conditions: People with certain pre-existing conditions (e.g., diabetes, hypertension) may still qualify but need additional approval.
4. Special Cases: If the individual is from a rural area or has served in the armed forces, their
eligibility criteria may be relaxed.
0.3.2
Instructions
Complete the following Python function by filling in the missing parts. Use *args for mandatory
inputs and **kwargs for optional parameters.
0.3.3
Code Snippet
“‘python def check_health_plan_eligibility(*args, **kwargs): “ “ ” Check eligibility for a health
insurance plan based on age, BMI, and pre-existing conditions. “ “ ” # Extract positional arguments
age, bmi, pre_existing_conditions = args
# Define default eligibility criteria
min_age = kwargs.get('min_age', 18) # Minimum age
max_age = kwargs.get('max_age', 65) # Maximum age
min_bmi = kwargs.get('min_bmi', 18.5) # Minimum BMI
max_bmi = kwargs.get('max_bmi', 30.0) # Maximum BMI
# Check special cases
rural = kwargs.get('rural', False)
veteran = kwargs.get('veteran', False)
# Adjust BMI threshold for rural residents
if rural:
# Fill in the adjustment logic for rural residents
max_bmi = _________________________
# Basic eligibility check
if ____________________________________:
return "Eligible for health plan"
# Special case: Veterans automatically qualify if age is within range
if ____________________________________:
return "Eligible under veteran plan"
# Special case: Rural residents with higher BMI
if ____________________________________:
return "Eligible under rural plan"
# If none of the conditions are met
return "Not eligible for health plan"
2
0.3.4
Example Input and Output
“‘python # Example 1: Standard applicant print(check_health_plan_eligibility(30, 25.0, False))
# Output: “Eligible for health plan”
1
Example 2: Rural applicant with relaxed BMI
print(check_health_plan_eligibility(40, 31.5, False, rural=True)) # Output: “Eligible under rural
plan”
2
Example 3: Veteran with pre-existing conditions
print(check_health_plan_eligibility(50, 28.0, True, veteran=True)) # Output: “Eligible under
veteran plan”
3
Example 4: Ineligible due to age
print(check_health_plan_eligibility(70, 26.0, False)) # Output: “Not eligible for health plan”
[ ]:
3
Download