πŸ“˜ Lesson 1 examples: Introduction to Python

Here are more beginner-friendly examples for Lesson 1: Introduction to Python, with clear explanations and practical use cases. These are perfect if you’re just starting or teaching Python basics.


1️⃣ Python as a Calculator

print(10 + 5)
print(20 - 7)
print(4 * 6)
print(20 / 4)
print(10 % 3)   # Remainder
print(2 ** 3)   # Power

Output

15
13
24
5.0
1
8

2️⃣ Printing Multiple Values

name = "Ali"
age = 25
city = "Delhi"

print(name, age, city)

Output

Ali 25 Delhi

3️⃣ Using type() to Check Data Type

x = 10
y = 3.5
z = "Python"
is_active = True

print(type(x))
print(type(y))
print(type(z))
print(type(is_active))

4️⃣ Simple Variable Usage

price = 100
quantity = 3
total = price * quantity

print("Total price:", total)

5️⃣ String Examples

message = "Welcome to Python"
print(message.upper())
print(message.lower())
print(message[0])
print(message[-1])

6️⃣ Taking User Input

name = input("Enter your name: ")
print("Hello", name)

7️⃣ Converting Input Data Type

age = int(input("Enter your age: "))
print("Next year you will be", age + 1)

8️⃣ Simple Program: Student Info

name = input("Enter student name: ")
marks = int(input("Enter marks: "))

print("Student:", name)
print("Marks:", marks)

9️⃣ Comments in Python

# This is a single-line comment

"""
This is a
multi-line
comment
"""
print("Comments example")

πŸ”Ÿ Python Is Case-Sensitive

name = "Python"
Name = "Programming"

print(name)
print(Name)

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *