Project: Your First Python Program
Project Summary
In this project, you will create a simple Python program that asks for the user’s name, greets them with their name, and calculates their age in a future year. This project aims to familiarize you with basic Python syntax, input/output operations, and simple arithmetic operations.
Prerequisites
To complete this project, you should have a basic understanding of the following concepts:
- Python variables and data types
- Input/output operations
- Arithmetic operations
If you haven’t learned these concepts yet, you can start by reading the following resources:
Project Description
You will write a Python script that performs the following tasks:
- Greet the User: When the program starts, it should print a message like “Welcome to the Python program!” to the console.
- Ask for the User’s Name: Prompt the user to enter their name and read their input from the console.
- Greet the User by Name: After getting the user’s name, greet them by name. For example, if the user’s name is “Alice”, the program should print “Hello, Alice!”.
- Calculate Age in a Future Year:
- Ask the user to enter their current age.
- Ask the user for a future year.
- Calculate and print the user’s age in that future year.
Example of Outcome
Here’s what the interaction with your program might look like:
Welcome to the Python program!
Please enter your name: Alice
Hello, Alice!
Please enter your current age: 30
Enter a future year: 2030
In 2030, you will be 40 years old.
Challenges or Milestones
- Basic Implementation: Implement the program with basic input/output operations and arithmetic calculations.
- Input Validation: Add input validation to ensure the user enters valid numbers for age and the future year.
- Current Year Calculation: Use the
datetime
module to automatically fetch the current year instead of asking for the user’s current age.
Project Template
Here’s a starting template for your project:
# Your First Python Program
def main():
print("Welcome to the Python program!")
# Step 1: Ask for the user's name
# Step 2: Greet the user by name
# Step 3: Calculate age in a future year
# Your code here
if __name__ == "__main__":
main()
Conclusion
This project is designed to help you practice basic Python programming concepts, including working with variables, input/output operations, and basic arithmetic operations. Completing it will give you a good foundation for more complex Python projects in the future.