|
1 | 1 | # EXAMPLES NOT FOR USE |
2 | 2 | # -------------------- |
3 | 3 |
|
4 | | -import os |
5 | 4 | import time |
6 | 5 |
|
7 | | -# Clear the console |
8 | | -os.system('cls' if os.name == 'nt' else 'clear') |
| 6 | +# Parameterize the sleep duration |
| 7 | +SLEEP_DURATION = 1 |
| 8 | + |
| 9 | +def clear_console(): |
| 10 | + # Clear the console (optional, can be omitted if not necessary) |
| 11 | + import os |
| 12 | + os.system('cls' if os.name == 'nt' else 'clear') |
| 13 | + |
| 14 | +clear_console() |
9 | 15 |
|
10 | 16 | print("Hello coding community!") |
11 | | -time.sleep(1) |
| 17 | +time.sleep(SLEEP_DURATION) |
12 | 18 |
|
13 | 19 | language = "Python" # String |
14 | 20 | dreamjobtitle = "videogame development" |
15 | 21 | print(f"{language} is my favorite language for programming. My favorite dream job that I want to get is {dreamjobtitle}.") |
16 | | -time.sleep(1) |
| 22 | +time.sleep(SLEEP_DURATION) |
17 | 23 |
|
18 | 24 | age = 20 # Define the age variable with a sample value |
19 | 25 |
|
20 | 26 | if age < 18: |
21 | 27 | print("Student") |
| 28 | +elif 18 <= age <= 25: |
| 29 | + print("Junior Developer") |
22 | 30 | else: |
23 | | - if age >= 18 and age <= 25: |
24 | | - print("Junior Developer") |
25 | | - else: |
26 | | - print("Senior Developer") |
27 | | -time.sleep(1) |
28 | | - |
29 | | -def calculate_income(monthly_salary): |
30 | | - mid_income = monthly_salary * 6 |
31 | | - return mid_income |
| 31 | + print("Senior Developer") |
| 32 | +time.sleep(SLEEP_DURATION) |
| 33 | + |
| 34 | +def calculate_six_month_income(monthly_salary): |
| 35 | + """ |
| 36 | + Calculate income for a six-month period based on the monthly salary. |
| 37 | + |
| 38 | + Args: |
| 39 | + monthly_salary (float): Monthly salary amount. |
| 40 | + |
| 41 | + Returns: |
| 42 | + float: Total income for six months. |
| 43 | + """ |
| 44 | + six_month_income = monthly_salary * 6 |
| 45 | + return six_month_income |
32 | 46 |
|
33 | 47 | # Example usage |
34 | 48 | monthly_salary = 1000 |
35 | | -mid_income = calculate_income(monthly_salary) |
36 | | -print(f"The mid income for 6 months is ${mid_income}") |
| 49 | +six_month_income = calculate_six_month_income(monthly_salary) |
| 50 | +print(f"The income for 6 months is ${six_month_income:.2f}") |
37 | 51 |
|
38 | 52 |
|
39 | 53 | # STUDENT PASSED ACTIVITY |
0 commit comments