Welcome to the Git Exercise repository! This repository contains 20 simple Python programming exercises designed to help you practice both Python programming and Git version control.
Each student should work on their assigned exercise:
- Exercise 1 - Hello World (Student 1)
- Exercise 2 - Sum Two Numbers (Student 2)
- Exercise 3 - Check Even or Odd (Student 3)
- Exercise 4 - Find Maximum (Student 4)
- Exercise 5 - String Length (Student 5)
- Exercise 6 - List Sum (Student 6)
- Exercise 7 - Reverse String (Student 7)
- Exercise 8 - Count Vowels (Student 8)
- Exercise 9 - Factorial (Student 9)
- Exercise 10 - Is Palindrome (Student 10)
- Exercise 11 - Multiply List (Student 11)
- Exercise 12 - Count Words (Student 12)
- Exercise 13 - Temperature Converter (Student 13)
- Exercise 14 - Find Minimum (Student 14)
- Exercise 15 - List Average (Student 15)
- Exercise 16 - Remove Duplicates (Student 16)
- Exercise 17 - FizzBuzz (Student 17)
- Exercise 18 - String to Uppercase (Student 18)
- Exercise 19 - Is Prime (Student 19)
- Exercise 20 - Square Numbers (Student 20)
First, clone this repository to your local machine:
git clone https://github.com/brain-bremen/GitExercise.git
cd GitExerciseEach student should create their own branch. Replace X with your student number (01-20):
git switch -c student-XFor example, if you are Student 5:
git switch -c student-5- Open your assigned exercise file (e.g.,
exercise_05.pyfor Student 5) - Read the task description in the comments
- Implement the required function
- Test your code by running the file:
python exercise_05.pyOnce you've completed your exercise, save and commit your changes:
# Check which files have been modified
git status
# Add your exercise file to staging
git add exercise_05.py
# Commit your changes with a meaningful message
git commit -m "Completed exercise 5: String Length"Push your branch to the remote repository:
git push origin student-5If this is your first push on this branch, Git might ask you to set the upstream branch:
git push -u origin student-5Here are some helpful Git commands you might need:
# Check current branch
git branch
# View commit history
git log
# View changes you've made
git diff
# Discard changes in a file (be careful!)
git checkout -- exercise_05.py
# Pull latest changes from main branch
git pull origin main
# Switch back to main branch
git checkout main
# Switch to your branch
git checkout student-5- Test your code before committing - make sure it runs without errors
- Write clear commit messages - describe what you changed
- Use your own branch - don't work on the main branch or other students' branches
- Ask for help if you get stuck with Git or Python
- Save often and commit regularly
Problem: git push is rejected
- Solution: Make sure you're on your own branch:
git branch
Problem: Changes not showing up
- Solution: Make sure you saved the file and added it:
git add exercise_XX.py
Problem: Merge conflicts
- Solution: Ask your instructor for help
If you encounter any issues with Git or the exercises, don't hesitate to ask your instructor or classmates for help!
Happy coding! 🎉