notebooklm
1. Project structure
leap-year-checker/
├── leap_year.py
└── README.md2. Python program — leap_year.py
# Leap Year Checker
year = int(input("Enter a year: "))
if year % 400 == 0:
print(f"{year} is a leap year.")
elif year % 100 == 0:
print(f"{year} is not a leap year.")
elif year % 4 == 0:
print(f"{year} is a leap year.")
else:
print(f"{year} is not a leap year.")
How it works
A year is a leap year if:
It is divisible by 400, or
It is divisible by 4 but not divisible by 100.
Examples:
Enter a year: 2024
2024 is a leap year.Enter a year: 1900
1900 is not a leap year.Enter a year: 2000
2000 is a leap year.3. GitHub README — README.md
Create a file named README.md in your project folder and copy the following content.
🗓️ Leap Year Checker
A simple Python program that prompts the user to enter a year and determines whether it is a leap year.
📌 About the Project
This project is a beginner-friendly Python exercise designed to practice user input, conditional statements, and arithmetic operators.
✨ Features
- Accepts a year from the user.
- Checks whether the year is a leap year.
- Displays a clear result.
- Uses simple Python conditional statements.
🛠️ Built With
- Python 3
📂 Project Structure
leap-year-checker/
├── leap_year.py
└── README.md
🚀 Getting Started
Prerequisites
Install Python 3 on your computer.
Check your Python installation by running:
python --version
Installation
- Clone this repository:
git clone https://github.com/YOUR-USERNAME/leap-year-checker.git
- Navigate to the project directory:
cd leap-year-checker
- Run the Python program:
python leap_year.py
💻 Usage
Enter a year when prompted by the program.
Example:
Enter a year: 2024
2024 is a leap year.
Another example:
Enter a year: 1900
1900 is not a leap year.
📖 Leap Year Rules
A year is a leap year if:
- It is divisible by 400; or
- It is divisible by 4 but not divisible by 100.
For example:
| Year | Result |
|---|---|
| 2024 | Leap year |
| 2023 | Not a leap year |
| 1900 | Not a leap year |
| 2000 | Leap year |
🎯 Learning Objectives
- Understand Python's
input()function. - Convert user input into an integer using
int(). - Use
if,elif, andelsestatements. - Apply the modulo operator (
%) to check divisibility.
🤝 Contributing
Contributions, suggestions, and improvements are welcome. Feel free to fork this repository and submit a pull request.
📄 License
This project is available under the MIT License. Add a LICENSE file to the repository if you wish to distribute it under that license.
👤 Author
YOUR NAME
GitHub: @YOUR-USERNAME
4. Upload the project to GitHub
Create a new repository on GitHub .
Name it
leap-year-checker.Add
leap_year.pyandREADME.mdto your project.Commit and push the files to your repository.
If you're uploading through Git, run these commands inside your project folder:
git init
git add leap_year.py README.md
git commit -m "Add leap year checker"
git branch -M main
git remote add origin https://github.com/YOUR-USERNAME/leap-year-checker.git
git push -u origin mainReplace YOUR-USERNAME with your GitHub username.
Tip: Before publishing, replace the author placeholders in the README with your own details.











留言
張貼留言