🐍 Python Programming – Comprehensive Notes (Session 1 & 2)
Prepared by: Wisdom Eye Course
🧭 Session 1 – Foundations of Python
💻 1. Getting Started with Python and VS Code
Python is a beginner-friendly language known for its simplicity and readability. In this
course, we’ll use VS Code as our editor.
Steps to start:
1. Install Python (from [Link])
2. Install VS Code and the Python extension
3. Open your folder → Create a file → Save with .py extension
4. Use Run ▶ button or Terminal → Run Python File
💡
Tip: Enable Auto Save to avoid losing changes.
🖥️ 2. Input and Output in Python
print("Hello, World!") # Output
name = input("Enter your name: ")
print("Welcome,", name)
Note: All inputs from the user are treated as strings by default.
📦 3. Variables and Naming Rules
age = 22
name = "Arjun"
print("My name is", name, "and I am", age, "years old.")
Rules for naming variables:
• Must start with a letter or underscore (_)
• Cannot start with a number
• Can only contain letters, numbers, and underscores
• Case-sensitive (age, Age, and AGE are different)
🔢 4. Data Types in Python
Common Python Data Types: int, float, str, bool
x = input("Enter a number: ")
print(type(x)) # str
x = int(x)
print(type(x)) # int
➕ 5. Basic Operators
Arithmetic Operators: +, -, *, /, //, %, **
Operator precedence: (), **, *, /, //, %, +, -
🧠 Practice Problems
1. Write a Python program to take a number as input and print its square.
2. Take radius as input and find the area and perimeter of a circle.
3. Correct the following code:
❌ Fix: print(int(x) + 1)
x = input()
print(x + 1) #
4. Write a program to take your name and age, then print 'Hello [name], you are [age] years
old.'
⚙️ Session 2 – Decision Making and Logic
⚖️ 1. Relational Operators
Used to compare two values. Always return True or False.
Examples: ==, !=, >, <, >=, <=
🧩 2. Boolean Datatype
is_even = True
print(type(is_even)) # bool
🔀 3. Conditional Statements
age = int(input('Enter age: '))
if age >= 18:
print('You can vote!')
else:
print('You are too young to vote.')
🧠 4. Logical Operators
and – True if both are True
or – True if one is True
not – Negates result
5 > 2 and 3 < 10 # True
5 < 2 or 3 < 10 # True
not(5 > 2) # False
🪜 5. Nested Conditionals
gender = input('Enter gender (M/F): ')
age = int(input('Enter age: '))
if gender == 'M':
if age > 21:
print('Eligible for marriage')
else:
print('Not eligible')
elif gender == 'F':
if age > 18:
print('Eligible for marriage')
else:
print('Not eligible')
else:
print('Enter gender as M or F')
⚡ Common Mistakes to Avoid
• Using = instead of == in conditions
• Forgetting indentation after if or else
❌
• Mixing str and int without conversion
• Writing conditions like if x = 10: ( should be if x == 10:)
🧩 Session 2 – Practice Problems
1. Take two numbers a and b (where a > b) and check if a is divisible by b.
2. Take two numbers and print the larger one.
3. Extend the above for three numbers using:
(a) Nesting
(b) elif with logical operators
4. Write a program that prints grades based on marks:
90–100 → A
75–89 → B
50–74 → C
Below 50 → Fail
🏁 Quick Recap
Input/Output – use input() and print()
Variables – containers for data
Data Types – int, float, str, bool
Operators – Arithmetic + Logical
Conditionals – if, elif, else
Nesting – conditions within conditions
🧠 Think Like a Coder 💡
• Write a program that asks for age and prints 'You will turn 100 in the year ____.'
• Create a simple calculator that adds, subtracts, multiplies, and divides two numbers.