-
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathfirst_program.html
More file actions
131 lines (110 loc) · 4.24 KB
/
Copy pathfirst_program.html
File metadata and controls
131 lines (110 loc) · 4.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>First Program - NepaliCode</title>
<link rel="stylesheet" href="css/style.css">
<link rel="stylesheet" href="css/docs.css">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=Fira+Code:wght@400;500&display=swap" rel="stylesheet">
</head>
<body>
<!-- Navigation -->
<nav class="navbar">
<div class="container">
<div class="nav-brand">
<div class="logo">
<span class="logo-np">NP</span>
<span class="logo-text">NepaliCode</span>
</div>
</div>
<div class="nav-links">
<a href="index.html">Home</a>
<a href="installation.html">Installation</a>
<a href="syntax.html">Syntax</a>
<a href="https://github.com/NepaliSource/NepaliLang" target="_blank" class="github-btn">GitHub</a>
</div>
</div>
</nav>
<!-- Content -->
<section class="docs-content">
<div class="container">
<div class="docs-header">
<a href="index.html" class="back-link">← Back to Home</a>
<h1>Your First Program</h1>
<p class="docs-subtitle">Write and run your first NepaliCode program</p>
</div>
<div class="docs-body">
<h2>Hello World</h2>
<p>Let's start with the classic "Hello World" program in NepaliCode:</p>
<div class="code-block">
<pre><code># hello.np
print("Namaste Nepal!")</code></pre>
</div>
<h2>Running Your Program</h2>
<p>Save this code in a file called <code>hello.np</code> and run it:</p>
<div class="code-block">
<pre><code># Using Python
python main.py hello.np
# Using standalone executable
nepali.exe hello.np</code></pre>
</div>
<h2>Variables</h2>
<p>Let's make it more interesting with variables:</p>
<div class="code-block">
<pre><code># variables.np
name = "Diwas"
age = 21
city = "Kathmandu"
print(f"Name: {name}")
print(f"Age: {age}")
print(f"City: {city}")</code></pre>
</div>
<h2>Conditions</h2>
<p>Add some logic with Nepali keywords:</p>
<div class="code-block">
<pre><code># conditions.np
age = 18
yedi age >= 18:
print("You are an adult")
natra:
print("You are a minor")</code></pre>
</div>
<h2>Functions</h2>
<p>Create reusable functions:</p>
<div class="code-block">
<pre><code># 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")</code></pre>
</div>
<h2>Using Modules</h2>
<p>Import standard library modules:</p>
<div class="code-block">
<pre><code># modules.np
lyau ganit
print(f"5 + 3 = {ganit.jod(5, 3)}")
print(f"Square root of 16 = {ganit.sqrt(16)}")</code></pre>
</div>
<div class="note">
<p><strong>Next Steps:</strong> Check out the <a href="syntax.html">Syntax Reference</a> for more language features, or explore <a href="examples.html">50+ Examples</a> for practical programs.</p>
</div>
</div>
</div>
</section>
<!-- Footer -->
<footer class="footer">
<div class="container">
<div class="footer-bottom">
<p>© 2024 NepaliCode by Diwas Khatri. Made with ❤️ in Nepal 🇳🇵</p>
</div>
</div>
</footer>
</body>
</html>