Posts

Python OOP — Classes, Objects, and More | OOP made less scary, maybe! | TechAmbitionX

Image
Python OOP — Classes, Objects, and More | TechAmbitionX What is this Object-Oriented Programming thing? (OOP) Alright, let's break it down. OOP is a programming paradigm that uses "objects" to design software. Think of objects as real-world entities like cars, dogs, or even you! Each object has attributes (characteristics) and methods (actions). Easy Explanation: Imagine you want to describe something in real life, like a dog. You'd say what it looks like (its color, size) and what it can do (bark, run). OOP lets us write code that works the same way — by creating "things" (objects) with their own features and actions. Classes and Objects A class is like a blueprint for creating objects. An object is an instance of a class. Let's see an example: class Dog: def __init__(self, name): self.name = name def bark(self): print(f"{self.name} says woof!") my_dog = Dog("Doggy...

What the hell are functions in Python | TechAmbitionX | An easy guide by Mr. BILRED

Image
Python Functions — Defining, Returning & Using Arguments | TechAmbitionX What the hell is a Function in Python? Okay relax, you might've not opened the book, and exam is around the corner, but still, there's hope. HOPE! What is a Function? A function is a reusable block of code that performs a specific task. Functions help you organize code, avoid repetition, and make programs easier to understand. Got it? Creating Functions with def def greet(): print("Hello, TechAmbitionX!") This defines a function named greet . To use it, call it like this: greet() # Output: Hello, TechAmbitionX! Returning Values with return Functions can return values instead of printing them. This makes your code more flexible. def add(a, b): return a + b result = add(5, 3) print(result) # Output: 8 print() vs return print() displays output immediately. return sends data back to where the function was called, so you can store or use it later. ...

User Input in Python | Python Notes By Mr. BILRED - TechAmbitionX

Image
User Input in Python — Learn input(), int(), float(), and getpass() | TechAmbitionX User Input in Python — Talk to Your Code! What is User Input? User input means taking data from the user while the program is running . In Python, we use the built-in input() function. Basic Example name = input("What's your name? ") print("Hello, " + name + "!") Output: What's your name? Mr. BILRED Hello, Mr. BILRED! Want Numbers? Convert Them input() always returns a string . If you want a number, convert it like this: age = int(input("Enter your age: ")) print(age + 1) You Can Use float() too gpa = float(input("Enter your GPA: ")) print("apki GPA times 2 is", gpa * 2) Use Inputs in Real Programs username = input("Username: ") password = input("Password: ") print(f"Logging in as {username}...") 🔐 Optional: Hide Sensitive Input from getpass import getpass password = get...

Strings In Python - Python Notes By Mr. BILRED | TechAmbitionX

Image
Strings in Python — Say Hello to Text | TechAmbitionX Strings in Python — Say Hello to Text A string in Python is just a bunch of characters inside quotes. Single quotes or double quotes — both work: name = "Bilal" greeting = 'Hello World' empty = "" They can contain numbers, symbols, even emojis: info = "Python 3.11 rocks! 🤘" How to Use Strings in Python 1. Concatenation (Joining Strings) first = "Mr. " last = "BILRED" full = first + last print(full) # Mr. BILRED 2. String Length name = "Bilal" print(len(name)) # 5 3. Accessing Characters name = "Bilal" print(name[0]) # B print(name[-1]) # l 4. Slicing Strings (obv that means k "kaatna") print(name[0:3]) # Bil print(name[:4]) # Bila print(name[2:]) # lal 5. String Methods msg = "python is awesome" print(msg.upper()) # PYTHON IS AWESOME print(msg.capitalize()) # Python...

Python Data Types - Beginner Python Notes By Mr. Bilred - TechAmbitionX

Image
Python Data Types — What’s Inside the Box? | TechAmbitionX Python Data Types — What’s Inside the Box? So you’ve got a variable, like x = 5 Cool, but what type of thing is that? In Python, every value has a data type . Think of it like the kind of stuff inside the box. Common Python Data Types Integer (int): Whole numbers age = 21 Float: Decimal numbers pi = 3.14 String (str): Text name = "Bilal" Boolean (bool): True or False is_alive = True List: Collection of items fruits = ["apple", "banana", "cherry"] Dictionary (dict): Key-value pairs user = {"name": "Bilal", "age": 21} NoneType: Represents nothing result = None And remember, List have Square Brackets, And dictionary have Curly braces How to Check Data Type You can check what type something is using the type() function: print(type(...

What Are Variables In Python - Python Notes By Mr. BILRED - TechAmbitionX

Image
What Are Variables in Python? | TechAmbitionX What Are Variables in Python? Alright, let’s keep it simple. A variable is just a name that stores some value . Like a box with a label on it. When you write: x = 5 You’re saying: “Hey Python, make a box called x , and put the number 5 inside it.” Some Examples: name = "Bilal" age = 21 pi = 3.14 You can use these variables later in your program: print(name) print(age + 1) Variables Can Store: Numbers ( int , float ) Text (called strings ) Boolean values ( True or False ) Lists, dictionaries, and more Variable Naming Rules: In x = 10 "x" is the identifier for the variable storing the value 10. Try not to forget the following rules Don’t start names with a number No spaces allowed (use underscores like user_name ) Use meaningful names (atleast when you're showing that to your boss) Wanna Try? x = "Mr. BILRED" print("Welcom...

Your First Program In Python - Python Notes By Mr. BILRED - TechAmbitionX

Image
Learn Python - TechAmbitionX Okay, so you’ve decided to learn Python... Good, but wait, Why? (Go ask yourself) Now listen, I don't know for whatever reason you're learning Python Proglang, but this is what CAN be believed about it: Python is not just a language, it’s your gateway to automation, data science, web development, AI, and beyond. Today, start your Python journey with the absolute basics Python is a high-level, beginner-friendly programming language known for its clean syntax and readability. It’s used by tech giants like Google, Netflix, and NASA. Why Python? Easy to read, easy to write. Big companies use it (Google, Netflix, even NASA). Used in AI, Data Science, Machine Learning, Automation, you know! You can build websites, automate boring stuff, work on AI, or just mess around and learn. How to install Python Go to python.org and install the latest version of Python. Download any C...