Posts

Modi सरकार के ऊपर कटाक्ष BJP washing machine CBI ED

Image
  दैनिक भास्कर समाचार पत्र से लिया गया है 

MIddlewares in Express

  What is Middleware? Middleware in Express is like a security guard or helper that sits between the request (client) and the response (server) . It can modify, check, or handle requests before they reach the final destination (route handler). const express = require ( 'express' ); const app = express (); const port = 3000 const fs = require ( "fs" ) // Middleware function const logger = ( req , res , next ) => {     console . log ( `we are inside middleware` );     next (); // Move to the next middleware or route handler, if next() not written, req stop here..no further execution }; // Use middleware app . use ( logger ); app . use (( req , res , next ) => {     const timestamp = Date . now ();       const date = new Date ( timestamp );     console . log ( date . toString ());     fs . appendFileSync ( "logs.txt" , ` ${ date . toString () } is a ${ req . method } \n ` )   ...

BackEnd for WebDev

Image
 ye blog hinglish me likha gaya hai...jo samjh aaya uska bss notes hai BackEnd wali javascript: 1. Download NodeJs:  what is NodeJs;---- browser V8 engine,  Node.js is a runtime that lets you run JavaScript on a server to build fast and scalable web applications.  JavaScript talk directly to databases, files, and networks without needing a web browser. write this in terminal: npm init   [press enter] -->you can give project name, author etc,..to skip adding detail write {npm init -y} after this current folder.. becomes npm project, we can install packages..it becomes single entity,.. module/package -->borrowed code, written by someone else,..we are just importing to use it when you install any package,.. node_modules package appear in folder which holds packages and dependencies, helps to manage packages,...if node_modules  get deleted  "no worries"  dependencies are stored in package,json just write in terminal   [npm in...

Understanding Getters and Setters in Python

Understanding Getters and Setters in Python What are Getters and Setters in Python? In Python, getters and setters are methods that allow you to access and modify the values of private variables (usually prefixed with an underscore, like _variable ). They provide control over how attributes of an object are accessed and updated. Definitions: Getter: A method used to access the value of a private variable. Setter: A method used to update (or set) the value of a private variable. Getters and setters are useful to: Control access to private data. Validate data when setting a value. Include extra logic when getting or setting a value. Example without Getter/Setter: Consider the following example where we directly access a private variable: class Student: def __init__(self, name): self._name = name # Private variab...

Strings in python: Methods, Operations, and Reversing

Strings in Python: Methods, Operations, and Reversing Strings in Python: Methods, Operations, and Reversing In this article, we will learn about strings in Python, including how to create them, perform operations, use built-in methods, and reverse a string. Let’s dive in! 1. What is a String in Python? A string in Python is a sequence of characters enclosed in quotes ( ' ' or " " ). Strings can contain letters, numbers, spaces, and special characters. 2. Creating Strings You can create strings by using either single or double quotes: str1 = 'Hello' str2 = "World" str3 = '''This is a multi-line string''' 3. Common String Operations You can perform several operations on strings, such as concatenation, repetition, and slicing: Concatenation: Joining two strings using the + operator. ...

Learn about List, Tuples, Sets, Dictionaries in Python

Understanding Lists, Tuples, Dictionaries, and Sets in Python 1. Lists A list is a collection of items that are ordered and changeable. Lists allow duplicate members. my_list = [1, 2, 3, 4, 5] print(my_list) # Output: [1, 2, 3, 4, 5] my_list.append(6) # Adding an element print(my_list) # Output: [1, 2, 3, 4, 5, 6] Properties of Lists: Ordered: Items have a defined order. Mutable: Items can be changed. Allows duplicates: Multiple items can have the same value. 2. Tuples A tuple is similar to a list, but it is immutable. Once a tuple is created, you cannot change its values. my_tuple = (1, 2, 3, 4, 5) print(my_tuple) # Output: (1, 2, 3, 4, 5) # my_tuple[0] = 10 # This will raise a TypeError Properties of Tuples: Ordered: Items have a defined order. Immutable: Items cannot be changed. Allows duplicates: Multiple items can have the same value. ...

Learn all about Object Oriented Programming in Python | learn oops

Object-Oriented Programming in Python 1. Classes and Objects A class is like a blueprint for creating objects. An object is an instance of a class. In OOP, classes define the structure (attributes) and behavior (methods) of objects. class Car: def __init__(self, brand, model): self.brand = brand # attribute self.model = model # attribute def display_info(self): # method print(f"Car Brand: {self.brand}, Model: {self.model}") # Creating an object of the class Car my_car = Car("Toyota", "Corolla") my_car.display_info() # Output: Car Brand: Toyota, Model: Corolla 2. Scope Resolution In Python, the scope resolution operator ( :: in some languages) is replaced by dot notation ( . ). It is used to refer to a specific method or attribute in a class. class Student: school = "ABC School" # Class variable def __init__(self, name): self.name ...