Posts

DAY 4 OF PYTHON NOTES

DAY 4 OF PYTHON NOTES 🔹 1. for Loop Basics ✅ Syntax: python Copy Edit for variable in range (start, stop, step): # code block start : where to begin (default is 0) stop : where to end (not included!) step : how much to increment (default is 1) 🔹 2. Using range() 📘 Examples: python Copy Edit # Print 1 to 5 for i in range ( 1 , 6 ): print (i) # Print 0 to 9 for i in range ( 10 ): print (i) # Print even numbers from 2 to 10 for i in range ( 2 , 11 , 2 ): print (i) # Print in reverse (10 to 1) for i in range ( 10 , 0 , - 1 ): print (i) 🔹 3. Pattern Printing with Loops ✅ Print 5 stars: python Copy Edit for i in range ( 5 ): print ( "*" ) ✅ Print stars in one line: python Copy Edit for i in range ( 5 ): print ( "*" , end= " " ) ✅ Print triangle pattern: markdown Copy Edit * * * * * * * * * * python Copy Edit for i in range ( 1 , 5 ): print ( "* " * i) 🔹 4. Nested for Loops Us...

DAY 3 OF PYTHON NOTES

 DAY 3 OF PYTHON NOTES  🔹 1. Conditional Statements (if, elif, else) ✅ Basic Structure: python Copy Edit if condition: # code block elif another_condition: # another block else : # fallback block 📌 Example: python Copy Edit age = 18 if age >= 18 : print ( "You are an adult." ) elif age >= 13 : print ( "You are a teenager." ) else : print ( "You are a child." ) 🔹 2. Comparison Operators Operator Meaning == Equal to != Not equal to > Greater than < Less than >= Greater than or equal <= Less than or equal 🔹 3. Logical Operators Operator Meaning Example and True if both conditions a > 5 and a < 10 or True if one is true a < 5 or a > 15 not Negates the condition not(a == b) 🔹 4. Practice Problems Check if a number is even or odd . python Copy Edit num = int ( input ( "Enter a number: " )) if num % 2 == 0 : print ( "Even" ) else : print ( "Odd...