Welcome to the Python Introduction Tasks repository! This collection of Python scripts is designed to help you practice basic arithmetic operations, variable assignments, user input handling, and simple calculations. Let's get started!
Objective: Practice basic arithmetic operations in Python.
Instructions:
- Create
basic_operations.py
. - Define
number1
andnumber2
with values10
and5
. - Perform addition, subtraction, and multiplication.
- Print results in the format:
[operation] of [number1] and [number2] is [result]
.
Expected Output:
Addition of 10 and 5 is 15
Subtraction of 10 and 5 is 5
Multiplication of 10 and 5 is 50
Objective: Calculate simple interest using arithmetic operations.
Instructions:
- Create
simple_interest.py
. - Define
principal = 1000
,rate = 0.05
,time = 3
. - Calculate simple interest:
I = P * R * T
. - Print result:
The simple interest is: [interest]
.
Expected Output:
The simple interest is: 150.0
Objective: Calculate the area of a rectangle using length and width.
Instructions:
- Create
rectangle_area.py
. - Define
length = 10
andwidth = 5
. - Calculate area:
Area = length * width
. - Print result:
The area of the rectangle is: [area]
.
Expected Output:
The area of the rectangle is: 50
Objective: Convert hours to seconds.
Instructions:
- Create
hours_to_seconds.py
. - Define
hours = 2
. - Calculate seconds:
seconds = hours * 3600
. - Print result:
[hours] hour(s) is [seconds] seconds
.
Expected Output:
2 hour(s) is 7200 seconds
Objective: Calculate user's age in a future year based on current age input.
Instructions:
- Create
future_age_calculator.py
. - Prompt user for current age.
- Calculate age in 2050 (assuming current year is 2023).
- Print result:
In 2050, you will be [age] years old
.
Expected Output:
In 2050, you will be [age] years old
Objective: Calculate monthly savings and project annual savings with interest.
Instructions:
- Create
finance_calculator.py
. - Prompt user for monthly income and expenses.
- Calculate monthly savings:
Monthly Savings = Income - Expenses
. - Project annual savings with 5% interest.
- Print results.
Expected Output:
Your monthly savings are $[savings].
Projected savings after one year, with interest, is: $[projected_savings].
alx_be_python/
└── python_introduction/
├── basic_operations.py
├── simple_interest.py
├── rectangle_area.py
├── hours_to_seconds.py
├── future_age_calculator.py
└── finance_calculator.py
Execute each script using Python 3:
python3 <script_name>.py
This project is licensed under the MIT License.
Happy Coding! 🎉