Feedback

Chat Icon

Learn Git in a Day

Everything you need, nothing you don't

Put Your Code in the Cloud
47%

Push a Branch to GitLab

When you create a branch locally and want to share it, you need to push it explicitly. Let's try it:

git switch -c feature/square-root

Edit calculator.py to add a new function for square root:

cat << 'EOF' > calculator.py
# calculator.py - A simple calculator
# Hosted on GitLab

def add(a, b):
    """Add two numbers and return the result."""
    return a + b

def subtract(a, b):
    """Subtract b from a and return the result."""
    return a - b

def multiply(a, b):
    """Multiply two numbers and return the result."""
    return a * b

def divide(a, b):
    """Divide a by b and return the result."""
    if b == 0:
        return "Error: Cannot divide by zero"
    return a / b

def power(a, b):
    """Raise a to the power of b and return the result."""
    return a ** b

def modulo(a, b):
    """Return the remainder of a divided by b."""
    if b == 0:
        return "Error: Cannot divide by zero"
    return a % b

import math

def square_root(a):
    """Return the square root of a."""

Learn Git in a Day

Everything you need, nothing you don't

Enroll now to unlock all content and receive all future updates for free.

Unlock now  $9.99$7.49

Hurry! This limited time offer ends in:

To redeem this offer, copy the coupon code below and apply it at checkout:

Learn More