Learn Python in One Video in Nepali: A Beginner’s Guide
Python is one of the most popular programming languages today. It's beginner-friendly, versatile, and widely used in various fields, from web development to data science. If you are just starting out with Python and want to learn the basics, this guide is for you. Let’s explore the fundamentals of Python programming, one step at a time, all in one video tutorial, explained in Nepali!
1. Print Statement (प्रिन्ट स्टेटमेन्ट)
In Python, the print statement is used to display output on the screen. This is one of the first things you’ll learn.
pythonprint("नमस्ते, Python!")
Output:
नमस्ते, Python!
The print()
function helps you show any message, numbers, or even the result of calculations.
2. Input Statement (इनपुट स्टेटमेन्ट)
The input statement is used to take input from the user. You can prompt users to type something and store that value in a variable.
pythonname = input("तपाईको नाम के हो? ")
print("नमस्ते, " + name)
This will ask the user for their name and greet them.
3. Variables (भेरिएबल्स)
Variables are like containers that hold data. You can store different types of values such as numbers, strings, or lists in them.
pythonage = 25
name = "Ram"
height = 5.8
In Python, you don’t need to specify the data type explicitly. Python will figure it out.
4. Operators (अपरेटरहरू)
Operators in Python allow you to perform operations on variables and values. There are different types of operators:
Arithmetic Operators:
+
,-
,*
,/
pythonresult = 5 + 3 # Adds two numbers print(result)
Comparison Operators:
==
,!=
,>
,<
pythonprint(5 > 3) # True
Logical Operators:
and
,or
,not
pythonprint(5 > 3 and 2 < 3) # True
5. Lists (लिस्ट)
Lists are used to store multiple items in a single variable. A list can contain different data types.
pythonfruits = ["apple", "banana", "mango"]
print(fruits[0]) # Accessing the first item
You can add, remove, and modify items in a list.
6. Dictionary (डिक्सनरी)
A dictionary in Python is a collection of key-value pairs. It’s great for storing related data together.
pythonstudent = {"name": "Sita", "age": 21, "grade": "A"}
print(student["name"]) # Accessing value using a key
This allows you to map one set of values to another.
7. Tuples (टपल्स)
Tuples are similar to lists, but they are immutable, meaning you cannot change them after they are created.
pythoncolors = ("red", "green", "blue")
print(colors[1]) # Accessing the second item
Tuples are useful for fixed data that shouldn’t be altered.
8. Sets (सेट)
A set is an unordered collection of unique items. Sets are great for storing data without duplicates.
pythonnumbers = {1, 2, 3, 3, 4}
print(numbers) # Output will be {1, 2, 3, 4}
Sets are also useful for set operations like union, intersection, etc.
9. Conditionals (कन्डिसनल्स)
Conditional statements allow you to execute code based on certain conditions. In Python, you can use if
, elif
, and else
.
pythonage = 18
if age >= 18:
print("वयस्क")
else:
print("नाबालिग")
This checks the condition and prints accordingly.
10. Loops (लूप्स)
Loops help in running the same code multiple times. Python supports for
and while
loops.
For Loop: Used to iterate over a sequence.
pythonfor i in range(5): print(i)
While Loop: Keeps running until a condition is true.
pythoncount = 0 while count < 5: print(count) count += 1
11. Try Except (त्राई-एक्सेप्ट)
The try
and except
blocks are used to handle errors in Python. This prevents the program from crashing.
pythontry:
x = int(input("कुनै संख्या टाइप गर्नुहोस्: "))
print(x)
except ValueError:
print("संख्या टाइप गर्नुहोस्!")
This handles the case where the user enters something other than a number.
12. File Handling (फाइल ह्यान्डलिङ)
Python allows you to open, read, write, and close files using built-in functions.
python
file = open("data.txt", "w") # Open a file in write mode
file.write("This is a sample text.")
file.close()
You can also read data from files:
pythonfile = open("data.txt", "r")
content = file.read()
print(content)
file.close()
Conclusion
Learning Python can be fun and rewarding. Through this blog and the accompanying video tutorial, you’ll have a solid foundation in Python programming in Nepali. Keep practicing these basics, and soon, you’ll be building your own projects in Python!
Comments
Post a Comment