Python_In_Tamil-002 - Statements
Dear All,
Good Morning.
As explained in Python_In_Tamil-001, type the below codes in the Editor Window of IDLE, save them, run them. You will get the output/results in your Shell Window.
For Python_In_Tamil-002, the topic is Python Statements.
Python statements are instructions or commands that perform actions, control program flow, or manipulate data.
οΆ Assignment Statements:
age = 35
print(age)
name = "Govi"
print(name)
Assignment statements donβt produce results.
symbol is used to start writing a comment.
a = 5; b = -8
print(a + b)
οΆ Print Statement:
print("Hello, World!")
len = 5; wid = 8
print(βArea of triangle: β, (len * wid) / 2
οΆ Multi-line statements:
line continuation character ().
addition = 10 + 20 + \
30 + 40 + \
50 + 60 + 70
print(addition)
οΆ Implicit continuation:
addition = (10 + 20 +
30 + 40 +
50 + 60 + 70)
print(addition)
οΆ list of strings:
names = ['Arun',
'Balaji',
'Ganesh']
print(names)
οΆ dictionary name as a key and mark as a value:
students = {'Kadhir': 10,
'Kaavya': 11,
'Meena': 10}
print(students)
οΆ Conditional Statements:
x = 6
if x > 10:
print("x is greater than 10")
elif x == 10:
print("x is equal to 10")
else:
print("x is less than 10")
οΆ Loop Statements:
for i in range(6):
print(i)
x = 5
while x > 0:
print(x)
x -= 1
οΆ Function Definition Statements:
def greet(name):
print("Hello, " + name)
greet(βGoviβ)
οΆ Return Statement:
def add(a, b):
return a + b
result = add(4, 5)
print(result)
οΆ Import Statements:
import math
οΆ Exception Handling Statements:
try:
result = 10 / 0
except ZeroDivisionError:
print("Division by zero is not allowed.")
οΆ Break and Continue Statements:
for i in range(10):
if i == 5:
break # Exit the loop when i is 5
print(i)
οΆ pass Statement:
def placeholder_function():
pass
οΆ del statement:
my_list = [1, 2, 3]
del my_list[1]
If you have any comments/suggestions, please write your reviews.
Let us meet tomorrow with Python_In_Tamil-003.
Thanks and Regards
Govi
https://www.youtube.com/@Python_In_Tamil