Python_In_Tamil-002 - Statements
Govindarajan Shanm
Posted on July 9, 2024
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
Posted on July 9, 2024
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.