Skip to main content

Inbuilt Functions in Python पाइथन में अंतर्निहित फ़ंक्शन्स

Python is a powerful programming language that provides many inbuilt functions to make coding simple and efficient. These functions help programmers perform common tasks like finding length, converting characters, or checking memory addresses without writing extra code.

पायथन एक शक्तिशाली प्रोग्रामिंग भाषा है जो कई अंतर्निहित (inbuilt) फ़ंक्शन्स प्रदान करती है, जिससे कोडिंग आसान और प्रभावी हो जाती है। ये फ़ंक्शन प्रोग्रामर को सामान्य कार्य करने में मदद करते हैं जैसे लंबाई निकालना, अक्षरों का रूपांतरण करना या मेमोरी एड्रेस जांचना, और इसके लिए अतिरिक्त कोड लिखने की आवश्यकता नहीं होती।

(a) id() – Unique Identifier of an Object किसी वस्तु का अद्वितीय पहचानकर्ता

The id() function returns the unique memory address of an object. Every variable or object in Python is stored in memory, and id() helps us know where exactly it is stored.
id() फ़ंक्शन किसी ऑब्जेक्ट का अद्वितीय मेमोरी एड्रेस लौटाता है। पायथन में हर वेरिएबल या ऑब्जेक्ट मेमोरी में संग्रहित होता है और id() से हमें पता चलता है कि वह कहाँ स्थित है।

x = 10
print(id(x)) # Output: A unique memory address

(b) len() – Length of an Object किसी वस्तु की लंबाई

The len() function is used to find the number of elements in objects like strings, lists, tuples, etc. It is one of the most commonly used functions in Python.
len() फ़ंक्शन का उपयोग स्ट्रिंग, लिस्ट, ट्यूपल आदि जैसे ऑब्जेक्ट्स में तत्वों की संख्या पता करने के लिए किया जाता है। यह पायथन के सबसे अधिक उपयोग किए जाने वाले फ़ंक्शनों में से एक है।

name = "Python"
print(len(name)) # Output: 6

(c) chr() – ASCII to Character, ASCII से अक्षर में रूपांतरण

The chr() function converts an ASCII value (number) into its corresponding character. ASCII stands for American Standard Code for Information Interchange.
chr() फ़ंक्शन किसी ASCII मान (संख्या) को उसके संबंधित अक्षर में परिवर्तित करता है। ASCII का अर्थ है American Standard Code for Information Interchange

print(chr(65)) # Output: A
print(chr(97)) # Output: a

(d) ord() – Character to ASCII - अक्षर से ASCII मान

The ord() function does the opposite of chr(). It converts a character into its ASCII value. This is very useful in encryption, data processing, and character manipulation.
ord() फ़ंक्शन chr() का उल्टा काम करता है। यह किसी अक्षर को उसके ASCII मान में बदल देता है। यह एन्क्रिप्शन, डाटा प्रोसेसिंग और अक्षरों के प्रबंधन में बहुत उपयोगी है।

print(ord('A')) # Output: 65
print(ord('a')) # Output: 97

Comments

Popular posts from this blog

Filter function of python

filter function:-  Imagine we have a bunch of things, like a list of numbers, a collection of fruits, or any other group of items. Now, let's say we want to pick out only certain items from that group based on a specific condition. This is where the filter function comes in handy. Let's say we have a list of numbers, and we want to filter out only the even numbers. We define a condition-checking function that checks if a number is even. Then, we pass this function and the list of numbers to the filter function. It goes through each number, applies the condition-checking function, and keeps only the numbers that are even. Finally, it gives us a new list containing only the even numbers. def is_even(num):     return num % 2 == 0 numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] filtered_numbers = list(filter(is_even, numbers)) print(filtered_numbers) Output [2, 4, 6, 8, 10] We can also utilize lambda expressions to define filtering conditions directly within the filter function. nu...

The Python Interpreter पायथन इंटरप्रेटर

The Python interpreter is a program that executes Python code. It reads and interprets Python scripts or interactive commands, converting them into machine-readable bytecode for the computer to execute.The interpreter is a crucial component for running Python code, facilitating both learning and development processes. Users can interact with the interpreter in two primary modes: पायथन इंटरप्रेटर एक प्रोग्राम है जो पायथन कोड को निष्पादित करता है। यह पायथन स्क्रिप्ट या इंटरैक्टिव कमांड को पढ़ता है और व्याख्या करता है, उन्हें कंप्यूटर द्वारा निष्पादित करने के लिए मशीन-पठनीय बाइटकोड में परिवर्तित करता है। दुभाषिया पायथन कोड चलाने के लिए एक महत्वपूर्ण घटक है, जो सीखने और विकास दोनों प्रक्रियाओं को सुविधाजनक बनाता है। उपयोगकर्ता इंटरप्रेटर के साथ दो प्राथमिक मोड में बातचीत कर सकते हैं:- 1. Interactive Mode:- In this mode we can launch the Python interpreter in our terminal or command prompt without specifying a script.This mode allows us to enter Python commands and see immediate results...

Flow of execution of a python program पाइथन प्रोग्राम के निष्पादन का प्रवाह

Flow of execution represents a general outline of Python program execution. The specific flow can vary based on the program's structure, control flow statements (if, else, for, while), and function calls. निष्पादन का प्रवाह पायथन प्रोग्राम निष्पादन की एक सामान्य रूपरेखा का प्रतिनिधित्व करता है। विशिष्ट प्रवाह प्रोग्राम की संरचना, नियंत्रण प्रवाह विवरण (यदि, अन्यथा, के लिए, जबकि), और फ़ंक्शन कॉल के आधार पर भिन्न हो सकता है। 1.) Start: The program begins execution. 1.) प्रारंभ: प्रोग्राम का निष्पादन प्रारंभ होता है। 2.) Import Modules: If necessary, the program imports external modules or libraries. 2.) मॉड्यूल आयात करें: यदि आवश्यक हो, तो प्रोग्राम बाहरी मॉड्यूल या लाइब्रेरी आयात करता है। 3.) Define Functions: Any functions used in the program are defined. 3.) फंक्शन्स को परिभाषित करें: प्रोग्राम में उपयोग किए गए किसी भी फंक्शन को परिभाषित किया जाता है। 4.) Main Program: The main body of the program starts. 4.) मुख्य प्रोग्राम: प्रोग्राम का मुख्य भाग प्रारंभ होता है। 5.) Initializat...