Author: Saravana Kumar
-
Learn & Run Python Code Online – Best for Students & Beginners!
Live Python Editor 📤 Output will appear here… -
Python If Statement for Beginners – Learn with Fun Coding Exercises!
🚀 Python is fun for all ages! Today, let’s learn about the
if
condition in Python with easy-to-understand examples and outputs!The
if
statement helps the computer make decisions just like we do in real life. Let’s explore with examples!1. Basic If Condition
Example: Check if a number is positive.
num = int(input("Enter a number: ")) if num > 0: print("This is a positive number!")
Input:
5
Output:
This is a positive number!
🔹 Explanation: If the number is greater than 0, the message is printed. Otherwise, nothing happens.
2. If-Else Condition
Example: Check if a number is positive or negative.
num = int(input("Enter a number: ")) if num > 0: print("This is a positive number!") else: print("This is a negative number!")
Input:
'-3
Output:
This is a negative number!
🔹 Explanation: If the number is greater than 0, it prints “positive”; otherwise, it prints “negative”.
3. If-Else Condition
Example: Check if a number is positive, negative, or zero.
num = int(input("Enter a number: ")) if num > 0: print("This is a positive number!") elif num == 0: print("This is zero!") else: print("This is a negative number!")
Input:
0
Output:
This is zero!
🔹 Explanation: If the number is greater than 0, it prints “positive”. If it is 0, it prints “zero”. Otherwise, it prints “negative”.
4. Nested If Condition
Example: Check if a person is eligible to vote
age = int(input("Enter your age: ")) if age >= 18: if age >= 60: print("You are a senior citizen and can vote!") else: print("You can vote!") else: print("You are too young to vote!")
Input:
65
Output:
You are a senior citizen and can vote!
🔹 Explanation: If the number is greater than 0, it prints “positive”. If it is 0, it prints “zero”. Otherwise, it prints “negative”.
5. Even or Odd Number Check
num = int(input("Enter a number: ")) if num % 2 == 0: print("This is an even number!") else: print("This is an odd number!")
Input:
7
Output:
This is an odd number!
🔹 Explanation: If the number is divisible by 2, it’s even. Otherwise, it’s odd.
6.Check If a Year is a Leap Year
year = int(input("Enter a year: ")) if (year % 4 == 0 and year % 100 != 0) or (year % 400 == 0): print("This is a leap year!") else: print("This is not a leap year!")
Input:
2024
Output:
This is a leap year!
🔹 Explanation: A year is a leap year if it is divisible by 4 but not by 100 unless also divisible by 400.
7. Check If a Person Can Enter a Theme Park Ride
height = int(input("Enter your height in cm: ")) if height >= 120: print("You can go on the ride!") else: print("Sorry, you are not tall enough for the ride. ")
Input:
110
Output:
Sorry, you are not tall enough for the ride.
🔹 Explanation: If the height is 120 cm or more, the person can go on the ride. Otherwise, they cannot.
8. Check If a Student Passes the Exam
Example: Check if a person is eligible to vote
score = int(input("Enter your score: ")) if score >= 50: print("Congratulations! You passed the exam! ") else: print("Sorry, you failed. Try again next time! ")
Input:
45
Output:
Sorry, you failed. Try again next time!
🔹 Explanation: If the score is 50 or more, the student passes; otherwise, they fail.
4. Check If a Number is Between Two Values
num = int(input("Enter a number: ")) if 10 <= num <= 20: print("Your number is between 10 and 20!") else: print("Your number is outside the range!")
Input:
15
Output:
Your number is between 10 and 20!
🔹 Explanation:The condition
10 <= num <= 20
checks if the number falls within this range.10. Simple Yes/No Decision Game
choice = input("Do you like Python? (yes/no): ").lower() if choice == "yes": print("That's awesome! Python is great! ") else: print("No worries! Maybe you'll like it someday! ")
Input:
yes
Output:
That's awesome! Python is great!
🔹 Explanation: The program asks for input and checks if the answer is “yes” or “no”.
Final Thoughts: Why If Condition is Important?
✅ The if condition allows us to make decisions in Python, just like in real life!
✅ You can useif
,if-else
,if-elif-else
, and nested if conditions to create smart programs!
✅ These examples help beginners, students, and even adults learn Python easily!🚀 Want more fun Python lessons? Comment below and share this post with friends! 😊 Happy Coding! 🐍💻
-
SQLite Tutorial in Tamil – SQLite Browser Installation & SQL Queries
🚀 In this video, you will learn how to use SQLite Browser and write SQL queries step by step in Tamil. Perfect for beginners!
🔹 Topics Covered:
✔️ How to Install SQLite Browser
✔️ How to Create a Database & Tables
✔️ Insert, Update, Delete Queries
✔️ Using SQL Operators (>, <, =, AND, OR)
✔️ Group By & Order By Usage
✔️ Aggregate Functions (SUM, COUNT, AVG, MAX, MIN)📌 Watch the full video:
🎥How Download and Install SQLite Browser
You can download the latest version of SQLite Browser from the official website:👉 Download SQLite Browser OR, you can search for SQLite Browser on Google:
1. 👉 Follow the Steps 1 to 11 to Install Sqlite Browser
கீழே கொடுக்கப்பட்டுள்ள 1 முதல் 11 வரையிலான Step ஐ பயன்படுத்தி SQLite Browser நிறுவலாம்.If you found this helpful, Like, Comment, and Subscribe for more tutorials!
📢 Share this with your friends! -
Day 1: Introduction to SQLite
🎯 Objective
Learn what SQLite is, why it’s useful, and how to use it. By the end of this lesson, you will have created your first SQLite database!
What is SQLite? 📦✨
SQLite is a database, which is like a container for storing and organizing information.
🛠️ What Makes SQLite Special?
- 🚫 No server needed: Unlike other databases, SQLite doesn’t need extra software or servers.
- 📂 All in one file: Everything is saved in a single file on your device.
- 🌟 Easy to use: Perfect for beginners and small projects.
Why Use SQLite? ✅🎉
- 🛠️ Simple: Just download it and start using it.
- 📏 Lightweight: Small but powerful.
- 🚚 Portable: Easily move the database file anywhere.
- ⚡ Fast: Ideal for small to medium-sized tasks.
Where Is SQLite Used? 🌍
- 📱 Mobile Apps: Stores data like app settings or game progress.
- 🌐 Web Browsers: Chrome and Firefox use SQLite for saving history and bookmarks.
- 🛠️ Smart Devices: Found in smart TVs, washing machines, and other devices.
What is SQL? 💬✨
SQL stands for Structured Query Language, the language used to talk to databases.
Here’s what you can do with SQL:
- 🧐 Ask questions: “Show me the list of students in a class.”
- ➕ Add new data: “Add a new student to the database.”
- ✏️ Update data: “Change a student’s phone number.”
- ❌ Delete data: “Remove a student from the list.”
Hands-On Activity 🖐️💻
Let’s set up SQLite and create your first database!
Step 1: Download SQLite 📥
For Windows 10 Follow the Steps :
- Press
Win + R
, typemsinfo32
, and hit Enter.
2) Look for
System Type
:
If it saysx86-based PC
, your system is 32-bit.
If it saysx64-based PC
, your system is 64-bit.So My System says
x64-based PC
, My system is 64-bit.
3) Visit the official SQLite website.4) For 64-bit Windows (x64)> Right Click sqlite-tools-win64-3480000.zip> Save into D:\ (or) E:\ your choice
5) Extract the Folder as per below screen6) Right Click the following folder Rename it named sqlite
7) Now Folder Path : d:\sqlite
8) Now Press Windows Key + S > Type environ
9) Click Here Edit the System Environment Variable
10)Click Here Environment Variables
11) Click Path 12) Click Edit13) Click New
14) Enter D:\sqlite > Click OK in Edit Environment Variable Screen
15) Again OK in Environment Variables Screen
16) Again OK in System Properties Window17) Now Press Win Key + R (to Open Run Window)
18)To Check SQLite Installation ✅ :
Type CMD and Press Enter or Click OK to Open Command Prompt19) Now Type:
sqlite3
in Command Prompt
If you seesqlite>
you’ve installed SQLite successfully! 🎉
to Exit SQLite by typing:.exit
20) To Create Your First Database 📂
- Now Create a New Folder named mydb in D:\ or E:\ or F:\ your choice any drive
21) Now go to command prompt >
22) Next Enter sqlite3 myschool.db (This line create the Database)
23)
To Create Table follow the steps;;sqlite> create table students(id,name,age); (Press Enter)
To Insert Records
sqlite> insert into students(id,name,age) values(101,’Raja’,20); (Press Enter)sqlite> insert into students(id,name,age) values(102,’Kumar’,21);
To View Recordssqlite> select * from students;
Key Points to Remember 🧠✨
- SQLite is a simple, portable database system that works without a server.
- It’s lightweight and perfect for small projects like apps or personal data.
- SQL is the language we use to give instructions to the database.
🎉 By the end of today, you’ve created your first SQLite database. Great job! Keep practicing and exploring more about SQLite!
-
Merge data in Merged Table in Power point
- Inspect Table Code
Sub InspectTableStructure() Dim pres As Object Dim slide As Object Dim tableShape As Object Dim row As Integer Dim col As Integer Dim cellText As String Set pres = Application.ActivePresentation Set slide = pres.Slides(1) Set tableShape = Nothing Dim shp As Object For Each shp In slide.Shapes If shp.HasTable Then Set tableShape = shp Exit For End If Next shp If tableShape Is Nothing Then MsgBox "No table found on the slide!", vbExclamation Exit Sub End If Debug.Print "Inspecting table structure:" Debug.Print "Total rows: " & tableShape.Table.Rows.Count For row = 1 To tableShape.Table.Rows.Count Debug.Print "Row " & row & ":" For col = 1 To tableShape.Table.Rows(row).Cells.Count On Error Resume Next cellText = tableShape.Table.Cell(row, col).Shape.TextFrame.TextRange.Text If Err.Number = 0 Then Debug.Print " Column " & col & " - Text: " & cellText Else Debug.Print " Column " & col & " - Error: Cell not accessible." End If On Error GoTo 0 Next col Next row MsgBox "Table structure inspection complete! Check the Immediate Window (Ctrl+G) for details.", vbInformation End Sub
2. Merge Code
Sub PopulateExistingTable() Dim pptApp As Object Dim pres As Object Dim slide As Object Dim tableShape As Object Dim excelApp As Object Dim excelWorkbook As Object Dim excelSheet As Object Dim row As Integer Dim tableRow As Integer Dim tableColumn As Integer Dim excelFilePath As String excelFilePath = "F:\31.12.2024\combine\MyData1.xlsx" Set excelApp = CreateObject("Excel.Application") excelApp.Visible = False Set excelWorkbook = excelApp.Workbooks.Open(excelFilePath) Set excelSheet = excelWorkbook.Sheets(1) Set pptApp = CreateObject("PowerPoint.Application") pptApp.Visible = True If pptApp.Presentations.Count > 0 Then Set pres = pptApp.ActivePresentation Else MsgBox "No PowerPoint presentation is open!", vbExclamation Exit Sub End If row = 2 Do While excelSheet.Cells(row, 1).Value <> "" Dim newSlide As Object Set newSlide = pres.Slides(1).Duplicate newSlide.MoveTo pres.Slides.Count Set slide = pres.Slides(pres.Slides.Count) Set tableShape = Nothing Dim shp As Object For Each shp In slide.Shapes If shp.HasTable Then Set tableShape = shp Exit For End If Next shp If Not tableShape Is Nothing Then tableShape.Table.Cell(1, 12).Shape.TextFrame.TextRange.Text = excelSheet.Cells(row, 4).Value Else MsgBox "No table found on the slide!", vbExclamation Exit Sub End If '----------------------------------------- imagePath = excelSheet.Cells(row, 23).Value If Len(imagePath) > 0 And Dir(imagePath) <> "" Then On Error Resume Next Set imageRectangle = slide.Shapes("ImageRectangle") On Error GoTo 0 If Not imageRectangle Is Nothing Then imageRectangle.Fill.UserPicture imagePath Else MsgBox "Rectangle shape not found!", vbExclamation End If Else MsgBox "Invalid image path for row " & row, vbExclamation End If '----------------------------------------- row = row + 1 Loop excelWorkbook.Close False excelApp.Quit Set excelSheet = Nothing Set excelWorkbook = Nothing Set excelApp = Nothing MsgBox "Slides created and populated successfully!", vbInformation End Sub