← Back to Home

Your First Program

Write and run your first NepaliCode program

Hello World

Let's start with the classic "Hello World" program in NepaliCode:

# hello.np
print("Namaste Nepal!")

Running Your Program

Save this code in a file called hello.np and run it:

# Using Python
python main.py hello.np

# Using standalone executable
nepali.exe hello.np

Variables

Let's make it more interesting with variables:

# variables.np
name = "Diwas"
age = 21
city = "Kathmandu"

print(f"Name: {name}")
print(f"Age: {age}")
print(f"City: {city}")

Conditions

Add some logic with Nepali keywords:

# conditions.np
age = 18

yedi age >= 18:
    print("You are an adult")
natra:
    print("You are a minor")

Functions

Create reusable functions:

# functions.np
kaam greet(name):
    firta f"Namaste, {name}!"

kaam calculate_age(birth_year):
    current_year = 2024
    firta current_year - birth_year

print(greet("Nepal"))
print(f"You are {calculate_age(2000)} years old")

Using Modules

Import standard library modules:

# modules.np
lyau ganit

print(f"5 + 3 = {ganit.jod(5, 3)}")
print(f"Square root of 16 = {ganit.sqrt(16)}")

Next Steps: Check out the Syntax Reference for more language features, or explore 50+ Examples for practical programs.