Hi everyone! I am a first-year CSE student at P.A. College of Engineering, Mangalore. Coming from a non-CS background, these are the exact core concepts that helped me understand Python_
_ logic this week.
Taking Inputs from Users
To make a program interactive, we use the input() function.For Text: name = input("Enter your name: ")
For Numbers: age = int(input("Enter your age: "))
Key Note: We add int() around the input to tell Python to treat the text as a whole number!Showing Information
We use the print() function to display output on the screen.
Example: print("Hello", name)The Golden Rule of Operators
This is where most beginners make bugs!The Single Equals (=): Used to GIVE a value. (e.g., age = 18 means age is now 18).
The Double Equals (==): Used to CHECK a value. (e.g., age == 18 checks if age equals 18).
Not Equal To (!=): Used to check if values do not match. (e.g., age != 18).
-
Alignment Matters (Indentation)
In Python, structural alignment is everything. Your "if", "elif", and "else" code blocks must always be aligned perfectly at the exact same level, or your script will crash!
Top comments (0)