Go to GitHub.
Click "New Repository".
Name it something like my-first-python-project.
Add:
-
A description
-
A README file (tick this)
-
A Python .gitignore file
Click Create repository.
On your new repo, click the green “<> Code” button.
Click "Codespaces" tab, then “Create codespace on main”.
This launches a full development environment in your browser.
Inside Codespaces, in the left file panel:
Right-click → New File → name it hello.py.
Add this code:
print("Hello from Codespaces!")Press Run or use the Terminal:
python hello.pyMake a second file called about_me.py with some variables:
name = "Your Name"
age = 20
print(f"My name is {name} and I am {age} years old.")Now track your changes:
git add .
git commit -m "Add about_me.py"
git pushGo back to hello.py and change the message.
Add a second line of code.
Then commit again:
git add hello.py
git commit -m "Updated hello message"
git pushCreate a new branch in Terminal:
git checkout -b experimentingCreate a new file, e.g., calculator.py and write a simple sum:
print(10 + 5)Commit and push:
git add .
git commit -m "Added calculator script"
git push --set-upstream origin experimentingIn Codespaces, open the Source Control panel (left bar).
Explore the timeline of your commits and branches.
Note how each file changed over time.
Use basic terminal commands:
ls # lists files
cd folder # move into a folder
mkdir test # create a new folder
rm filename # delete a fileOptional: try editing files in the terminal using nano:
nano hello.pyCreate a .gitignore file and add:
*.log
*.csv
__pycache__/Save it, and make a commit:
git add .gitignore
git commit -m "Add gitignore"
git pushOpen the README.md file.
Add:
## About This Project
This is a sample Python project I'm building in GitHub Codespaces.
### Files
- `hello.py` – prints a welcome message
- `about_me.py` – prints your name and age
- `calculator.py` – does simple mathsCommit your changes:
git add README.md
git commit -m "Update README with project info"
git pushTask 11: Use input() to get user input in a Python file.
Task 12: Create a functions.py and define multiple reusable functions.
Task 13: Start working on a project (e.g. a calculator or simple data analysis script using lists).