LuSi's CoDEs
Kanalga Telegram’da o‘tish
Learn Telegram bot dev from Zero to Hero 🔰
Ko'proq ko'rsatish477
Obunachilar
Ma'lumot yo'q24 soatlar
Ma'lumot yo'q7 kunlar
Ma'lumot yo'q30 kunlar
Postlar arxiv
477
guys,, wda wagyk set una nica me tike tikk busy una 🥲 maybe next week wlin passe aai patan gnn pulwan. Ethkam poddak parna post tikath balala ready wela inn ,, ikmntama patan gnnw ❤️ethkm channel link ek yluwontath share krl sup ekk denn 🫶
477
Repost from ✘ ⏤͟͞ ᴅᴀʀᴋ ʟᴜᴄɪꜰᴇʀ 『🇱🇰』
Now you can customize telegram text font in desktop version !
Update Now ❤️
477
OTP Bypass Challenge Posted
Post Link : Click Here
Channel Link : Click Here
TRY YOUR LUCK
HAPPY HACKING 😂
477
Libraries කියන්නේ නිශ්චිත කාර්යයන් ඉටු කරගන්න pre-written, modules සහ functions වල එකතුවක්. Libraries මගින් විවිධ කර්යයන් සදහා tools සහ modules supply කරනවා වගේම, common tasks manage කරගෙන code එක කාර්යක්ශම කරගන්නත් libraries උදවු වෙනවා. අපි දැන් බලමු මොනාද මේ libraries, ඒවා install කරන්නෙ සහ use කරන්නේ කොහොමද කියලා. 🐍
=== 1. What are Libraries? ===
•
Libraries කියන්නේ mathematical operations, data manipulation, web development, machine learning වගේ කාර්යයන් ඉටු කරගනීමට සැකසුනු reusable codes අඩංගු modules collection එකක්. Libraries, common problems වලට ready-to-use විසදුම් ලබා දීමෙන් code එක විධිමත් කරන්න උදවු වෙනවා.
=== 2. Installing Libraries ===
• සාමාන්යයෙන් libraries install කිරීමට pip (Python Package Index) හෝ conda (Anaconda Distribution) වැනි package managersල use කරනවා. ඔයාට පුලුවන් terminal එකේ හෝ command prompt එකේ පහල තියෙන command එක run කරල library එකක් install කරගන්න.
pip install library_name
උදාහරණයක් විදියට numerical computing සදහා popular library එකක් වෙන NumPy library එක install කරන්න පහල තියෙන command එක run කරන්නොනි.
pip install numpy
=== 3. Using Libraries ===
• Library එකක් install කරගත්තට පස්සෙ, ඔයාට පුලුවන් ඒ library එකේ තියෙන functions, classes වගේ දේවල් import කරල use කරන්න. Library ඒකක් import කරද්දී import statement එකත් එක්ක අදාළ library එකේ name එක දෙන්න පුලුවන්.
import library_name
Then ඔයාට පුලුවන් ඒ library එකේ තියෙන functions සහ modules dot(.) එක use කරල access කරන්න.
import numpy
array = numpy.array([1, 2, 3, 4, 5])
print(array) # Output: [1 2 3 4 5]
ඔන්න ඉතිම් අවුරුදු නිවාඩුවෙන් පස්සෙ ආයිමත් වැඩ පටන් ගත්තා. මං හිතනවා දැන් හැමෝටම python basics හොදටම පුලුවන් ඇති කියලා. ඉතිම් හැමදාම වගේ අද කියපුවගෙත් තේරෙන්නැති දෙයක් තියේනම් discussion එකේ දාන්න. සුපුරුදු react එකත් දාල channel ලිංකුවත් share කරමු.Happy coding ! 🚀
@LuSiCoDEs | @LusiCoDEsDiss477
Guys, me tike post dnna wennah 🥲 gedr newei inne. Leave wenn ehma ep hode 🥲 ikmntma post gennm ❤️
477
Modules සහ packages වලින් වෙන්නේ ඔයාගෙ code එක reusable විදියට organize කරන එක සහ structure කිරීමයි. එහෙනම් අපි දැන් බලමු මොනාද මේ modules සහ packages කියන්නෙ, ඒවා හදන්නෙ සහ use කරන්නේ කොහොමද කියලා. 🐍
=== 1. Modules ===
•
Module එකක් කියන්නේ python code එකක් තියෙන file එකක්. එමගින් වෙනත් python script එකක ඇති Functions, Variables වගේ දේවල් import කරන්න සහ use කරන්න පුලුවන්. Modules, logical units organize කරන්න සහ code reuse කරන්න උදවු වෙනවා.
# Example module: math_operations.py
def add(x, y):
return x + y
def subtract(x, y):
return x - y
• මේකෙදි math_operations.py කියන්නේ add() සහ subtract() කියන functions 2ක define කරන module එකක්. ඔයාට පුලුවන් මේ functions 2ක වෙන python script එකකට import කරල use කරන්න.
=== 2. Packages ===
• Package කියන්නෙ module එකක් හෝ කිහිපයක් සහ __init__.py කියන special file එකක් සහිත directory එකක්. ඔයාට packages එකක් නම්කිරීමේ ගැටලු වළක්වා ගන්න සහ හොද code organization එකක් සපයන namespaces එකක් විදියට හිතන්නත් පුලුවන්.
my_package/
__init__.py
math_operations.py
string_operations.py
• my_package කියන්නේ math_operations.py සහ string_operations.py කියන modules දෙක සහිත package එකට. අර කලින් කිව්ව __init__.py කියන file එක ඕනි වෙන්නේ my_package කියන්නේ package එකක් කියල define කරන්න.
=== 3. Importing Modules and Packages ===
• Python වලදි ඔයාට පුලුවන් import කියන statement එක use කරල modules සහ packages import කරන්න. එහෙම module එකක් හෝ package එකක් import කරගත්තට පස්සෙ ඔයාට පුලුවන් ඒකෙ තියෙන functions, classes, සහ variables access කරන්න.
# Importing a module
import math_operations
result = math_operations.add(5, 3)
print(result) # Output: 8
# Importing specific functions from a module
from math_operations import subtract
result = subtract(10, 3)
print(result) # Output: 7
# Importing a package
import my_package.math_operations
result = my_package.math_operations.add(5, 3)
print(result) # Output: 8
හරි ඉතිම්, මේ modules and packages ගොඩක් වෙලාවට අපිට python සම්බන්ධ වැඩ වලදි අවශ්ය වෙනවා. අපි ඉස්සරහට පටන් ගන්න ඉන්න bot developing වලටත් මේ modules and packages ගොඩක් උදව් වෙනවා. So, පුලුවන් නම් මේ modules සහ packages ගැන වැඩිපුර හොයල study කරන්න Cuz self-study is the best way to learn (මමත් ඉස්සරහට කියල දෙනවා). එච්චරයි!!! හැමදාම වගේ ඉතිම් එක එක විදියෙ react දාල post එක ලස්සන කරන්න. Happy coding ! 🚀
@LuSiCoDEs | @LusiCoDEsDiss477
Exception handling වලින් වෙන්නේ ඔයාගෙ code එකේ තියෙන errors සහ unexpected events manage කරගන්න. Python හි, ඔයාට exceptions handle කරන්න try-except blocks use කරන්න පුලුවන්. 🐍
=== 1. Handling Exceptions with try-except Blocks ===
•
Try-except block එකෙන් පුලුවන් code block එකක තියෙන exceptions ටික catch කරන්න සහ handle කරන්න. Try block එකේ තියෙන්නෙ exception එන්න පුලුවන් code එක සහ except block එකේ තියෙන්නේ ඒ code එකේ exception එක handle කරන code එක.
try:
# Code that may raise an exception
result = 10 / 0 # ZeroDivisionError
except:
# Code to handle the exception
print("An error occurred")
මෙතනදි බිංදුවෙන් බෙදනකොට error එකක් ආවොත් except block එක ක්රියාත්මක වෙලා "An error occurred" කියන text එක print වෙනවා.
=== 2. Handling Specific Exceptions ===
• ඔයාට පුලුවන් exception type එකක් දීල specific error එකක් catch කරගන්න.
try:
# Code that may raise an exception
result = 10 / 0 # ZeroDivisionError
except ZeroDivisionError:
# Code to handle the ZeroDivisionError
print("Cannot divide by zero")
except:
# Code to handle other types of exceptions
print("An error occurred")
• මේ උදාහරණෙදි අපි ZeroDivisionError කියන exception එක විතරක් handle කරන්න ZeroDivisionError කියන exception type එක specify කරල දීල තියෙනවා. ඊට අමතරව වෙන exception එකක් ආවොත් ඒක except block එකෙන් handle කරන්නවා.
=== 3. Using finally Block ===
• Error එකක් තියේද නැද්ද කියන එක නොසලකා හැම වෙලේම run වෙන්නෝනි code එකක් specify කරන්න ඔයාට Finally block එක use කරන්න පුලුවම්.
try:
# Code that may raise an exception
result = 10 / 0 # ZeroDivisionError
except ZeroDivisionError:
# Code to handle the ZeroDivisionError
print("Cannot divide by zero")
finally:
# Code that always executes
print("End of try-except block")
හරි ඉතිම් ඔයාල මේව බලල try කරල බලන්න. ආස හිතෙයි 😂. අපි practical part එකකුත් කරනවා. So මේව study කරල තියාගන්න. ඒ වගේම තේරුන්නැති දේවල් තියේ නම් අහන්න. හැමදාම වගේ react එකකුත් දාල ගන්න එහෙනම්. Happy coding ! 🚀
@LuSiCoDEs | @LusiCoDEsDiss477
File handling කියන්නේ ඔයාගේ device එකේ file system එකේ තියෙන files එක්ක අන්තර් ක්රියා කරන programming වල තියෙන එක අංගයක්. Python වලදි built-in functions සහ methods use කරල ඔයාට ඕනම file එකක් read කරන්න සහ write කරන්න පුලුවම්. අපි දැන් බලමු file handling වල basics ටික. 🐍
=== 1. Opening a File ===
• ඔයාට file එකක් read කරන්න සහ write කරන්න කලින්
open() function එක use කරල ඒ file එක open කරන්න ඕනි. Open() function එක file එකේ path එක සහ file එක open කරන්න ඕනි mode එක(e.g., "r" for reading, "w" for writing, "a" for appending) කියන තර්ක 2ක් ගන්නවා.
# Opening a file for reading
file = open("example.txt", "r")
# Opening a file for writing
file = open("example.txt", "w")
# Opening a file for appending
file = open("example.txt", "a")
=== 2. Reading from a File ===
• කලින් කිව්ව විදියට file එකක් open කරගත්තම, ඔයාට පුලුවන් විවිධ ක්රම use කරල file එකක් read කරන්න. read(), readline() සහ readlines() කියන්නෙ ඒවගෙන් common methods ටිකක්.
# Reading the entire file
content = file.read()
print(content)
# Reading one line at a time
line = file.readline()
print(line)
# Reading all lines into a list
lines = file.readlines()
print(lines)
=== 3. Writing to a File ===
• ඔයාට පුලුවම් write() method එක use කරල file එකක් write කරන්න. මෙතනදි මතක තියාගන්න ඕනි දෙයක් තමයි ඔයා file එකක් write කරාට පස්සෙ අනිවාරෙන් ඒක close කරන්න ඕනි. නැත්තම් write කරපු data save වෙන්නේ නැහ්.
# Writing data to a file
file.write("Hello, world!\n")
file.write("This is a test.\n")
=== 4. Closing a File ===
• ඔයා file එකක් read හෝ write කරල ඉවර උනාට පස්සේ close() method එක use කරල අනිවාරෙන් close කරන්න ඕනි.
# Closing the file
file.close()
=== 5. Using "with" Statement ===
• Error එකක් තිබුනත් file එකක් හරියට close කරල කියල confirm කරන්න ඔයාට පුලුවන් with statement එක use කරන්න. එමගින් read or write කරපු file එකක් automatically close කරන්න පුලුවම්.
with open("example.txt", "r") as file:
content = file.read()
print(content)
=== All in one example ===
# Open a file for writing
with open("example.txt", "w") as file:
# Write data to the file
file.write("Hello, world!\n")
file.write("This is a test.\n")
# Open the same file for reading
with open("example.txt", "r") as file:
# Read the entire file
content = file.read()
print("File content:")
print(content)
ඉස්සෙල්ලම corry කියන්නෝනි දවස් 4කින් විතර post දාන්න බැරි උනාට. හැබෙයි පට්ට happy & ගොඩක් thnks මොකද එහෙම වෙලත් එක්කෙනෙක්වත් left වෙලා නැහ්. මන් පුලුවම් තරම් try එකක් දෙනෝ daily පෝස්ට් දාන්න. මොකද මේක නෙවෙයි මන් හිතන් හිටපු දේ. ඒත් එක්කෙනෙක්ට හරි මේ වැඩෙන් උදව්වක් වෙනව නම් ඉතිම් එච්චරයි. මට මේ channel එකේ sub වැඩි කරගන්න නෙවෙයි මේ වැඩෙන් ප්රයෝජන ගන්න set එකක් ඕනි. Anyway හැමදාම වගේ අදත් තේරුන්නැති දෙයක් තියේ නම් discussion එකේ දාන්න. ඒ වගේම ඉතිම් react එකක් දාල programming දන්නැති ඔයාගෙ මෝඩ යාලුවට channel link එක share කරාට තරහ වෙන්නෙ නෑ. Happy coding ! 🚀
@LuSiCoDEs | @LusiCoDEsDiss477
Functions කියන්නෙ සරලවම ඔයාට code set එකක් නැවත නැවත use කරන්න ඕන උනාම ඒක තනි code block එකක් කරන්න පුලුවන් දෙයක්. මේ functions ගොඩක්ම use වෙන්නෙ algorithm, logics වගේ දේවල් වලට වගේම ඔයාගෙ code එක කෙටි කරගන්නත් මේ function උදව් වෙනවා. අපි දැන් බලමු කොහොමද මෙ function use කරන්නෙ කියලා. 🐍
=== 1. Defining a Function ===
• function එකක් use කරද්දි ඔයාට
def කියන keyword එකත් එක්ක function එකේ නම දීල වරහනක් දන්න පුලුවන්. ඊට පස්සෙ මේ example එකේ වගේ ඔයාට ඕනි code එක දීල ඒ function එක call කරන හැම වෙලාවකදිම ඒ code එක run වෙනවා.
def greet():
print("Hello, world!")
def add(x, y):
return x + y
මෙතනදි මේ greet() කියන function එක use වෙන හැම වෙලාවකදිම "Hello, world!" කියල display වෙනවා. ඒ වගේම තමයි add(x, y) කියන function එකෙ x සහ y කියන variable 2ට අගයන් 2ක් ආදේශ කරාම ඒ දෙක එකතු වෙනවා.
=== 2. Calling a Function ===
• දැන් බලමු define කරපු function එක call කරන විදිය. මන් හිතනවා කියනවට වඩා ඔයාට මේ දීල තියෙන examples බලල ඒක තේරුම් ගන්න පුලුවන් වෙයි කියලා.
greet() # Output: Hello, world!
result = add(3, 5)
print(result) # Output: 8
• මං කලින් කිව්ව වගේ greet() function එක call කරාම "Hello, world!" කියල print වෙනව සහ add(x, y) හි විචල්යන්ට අගයන් ආදේශ කරාම ඒ අගයන් 2ක එකතු වෙනවා.
කියන්න නම් තියෙන්නෙ එච්චරයි. මන් කියපු දෙයක් තේරුන්නැතත් හැමදාම කියනව වගේ examples බලල ගොඩක් වෙලාවට ඔයාට ඕනි එකක් තේරුම් ගන්න පුලුවන්. එහෙමත් තේරෙන්නැති දෙයක් තියේ නම් discussion එකේ දාන්න. corry වෙන්නෝනි අධික කාර්යබහුලත්වය නිසා අද post එක දාන්න පරක්කු උනාට. ඉතිම් මෙහෙම busy වෙලාවෙත් පුලුවන් විදියට post දාන එකෙන් ප්රයොජනයක් ගන්න සහ සුපුරුදු react එකත් දාන්න අමතක කරන්නෙපා. Happy coding ! 🚀
@LuSiCoDEs | @LusiCoDEsDiss