Posts

Simple python programs..

 Here are some simple Python programs for beginners: 1. Print Hello World print ( "Hello World" ) 2. Add Two Numbers a = int ( input ( "Enter first number: " )) b = int ( input ( "Enter second number: " )) print ( "Sum =" , a + b ) 3. Odd or Even num = int ( input ( "Enter a number: " )) if num % 2 == 0 : print ( "Even" ) else : print ( "Odd" ) 4. Find Largest Number a = int ( input ( "Enter first number: " )) b = int ( input ( "Enter second number: " )) if a > b : print ( a , "is larger" ) else : print ( b , "is larger" ) 5. Print Numbers 1 to 10 for i in range ( 1 , 11 ): print ( i ) 6. Multiplication Table num = int ( input ( "Enter a number: " )) for i in range ( 1 , 11 ): print ( num , "x" , i , "=" , num * i ) 7. Count Vowels in a Name name = input ( "Enter y...

Codes

Image
--------------------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------------------------------------

🐍 30-Day Python Course Notes (Beginner to Intermediate)

  🐍 30-Day Python Course Notes (Beginner to Intermediate) 📅 WEEK 1: Python Basics Day 1: Introduction to Python What is Python? Applications (Web, AI, Automation, Data Science) Install Python & IDE (VS Code / IDLE) First Program: print("Hello World") Day 2: Variables & Data Types Variables Data types: int, float, str, bool x = 10 name = "Rohith" Day 3: Input & Output name = input("Enter your name: ") print("Hello", name) Day 4: Operators Arithmetic (+, -, *, /) Comparison (>, <, ==) Logical (and, or, not) Day 5: Conditional Statements age = 18 if age >= 18: print("Adult") else: print("Minor") Day 6: Loops (for, while) for i in range(5): print(i) Day 7: Practice + Mini Project Number guessing game 📅 WEEK 2: Data Structures Day 8: Lists nums = [1, 2, 3] nums.append(4) Day 9: Tuples t = (1, 2, 3) Day 10: Sets s = {1, 2, 3} Day 11: Dictionaries student = {"name": "Rohith", ...

Lesson: Debugging in Python

  Lesson: Debugging in Python [introduction] Welcome back! Today we’re exploring debugging , one of the most essential skills for every programmer. Debugging is simply the process of finding and fixing errors in your code. By the end of this lesson, you’ll understand common error types, debugging techniques, and tools that will help you solve problems confidently. [concept_explanation] Debugging involves identifying where and why something is going wrong in your program. Python provides several types of errors: 1. Syntax Errors Mistakes in the structure of your code. Example: missing parentheses, colon, or using wrong indentation. 2. Runtime Errors Errors that happen while the program runs. Example: dividing by zero, using a variable that doesn’t exist. 3. Logic Errors The code runs, but the output is incorrect. Example: Using + instead of * . To debug effectively, you must learn to: Read error messages Trace what the code is doing Test small parts of y...

Lesson: File Handling in Python

  Lesson: File Handling in Python [introduction] Welcome back! Today we’ll learn about file handling , which allows Python programs to read from and write to files. This is essential for saving data, loading data, creating logs, and interacting with the real world outside your program. By the end of this lesson, you’ll understand how to open, read, write, append, and safely manage files. [concept_explanation] File handling in Python revolves around the built-in open() function. The general pattern is: file = open ( "filename" , "mode" ) # work with the file file.close() But the recommended modern way is using a with-statement , which automatically closes the file: with open ( "filename" , "mode" ) as file: # work with the file Common File Modes Mode Meaning "r" Read (default) "w" Write (overwrites file) "a" Append (adds to file) "x" Create (fails if file exists) "b" Binary mod...

Lesson: OOP (Object-Oriented Programming) in Python by prompt AI teaching assistant

  Lesson: OOP (Object-Oriented Programming) in Python [introduction] Welcome back! Today we’ll explore Object-Oriented Programming (OOP) , a powerful way to structure and organize Python programs. By the end of this lesson, you’ll understand classes, objects, attributes, methods, and why OOP is so useful. [concept_explanation] OOP is a programming style built around objects . An object is something that has: Attributes (data → variables inside the object) Methods (behavior → functions inside the object) In Python, OOP centers around classes , which are blueprints for creating objects. Key concepts you must know: Class — a blueprint or template Object / Instance — a concrete version of a class Attributes — variables that belong to an object Methods — functions that belong to an object __init__ method — the constructor, runs when you create an object self keyword — refers to the current object, required in methods OOP helps with code or...

Lesson: Strings in Python ( by prompt AI teaching assistant )

  Lesson: Strings in Python [introduction] Welcome back! Today we’re learning about strings , one of the most important and commonly used data types in Python. By the end of this lesson, you’ll understand how strings work, how to manipulate them, and how to use many common string operations. [concept_explanation] A string is a sequence of characters—letters, numbers, symbols—surrounded by quotes. You can create strings using: "double quotes" 'single quotes' Both work the same way. Key characteristics: Strings are immutable (you can’t change characters directly). They support indexing and slicing . Python treats strings as sequences, so you can loop through them. They come with many built-in methods (like .upper() , .split() , .replace() ). [python_examples] 1. Creating a string message = "Hello, Python!" 2. Indexing print (message[ 0 ]) # H print (message[ 7 ]) # P 3. Slicing print (message[ 0 : 5 ]) # Hello ...