Python simple and easy to learn
from math import pi
check_data=True
check_value = True
check_sample =True
letters="Hello Krishna"
numbers = [6,7,8]
if check_data:
print ("Hello World" " " "Moorthi")
if check_sample:
print ("Hello Moorthi")
if check_value == False:
print ("I am in False")
elif check_value == True:
print ("I am in \n True")
else:
print ("Checking")
for char in letters:
print (char)
total=0
for num in numbers:
total = total + num
print ("Total : ",total)
for test in numbers:
pass
def krishnaMethod():
""" Documentation """
print ("I am inside method ",min(numbers))
krishnaMethod()
def greet(*names, msg = "Good morning!"):
"""
This function greets to
the person with the
provided message.
If message is not provided,
it defaults to "Good
morning!"
"""
for name in names:
print("Hello",name + ', ' + msg)
greet("Kate","krishna","Moorthi")
greet("Bruce",msg="How do you do?")
print("Pi Value : ",pi)
while True:
try:
validnumber=int(input("Please eneter number :"))
break
except:
print("Invalid data")
Output:
from math import pi
check_data=True
check_value = True
check_sample =True
letters="Hello Krishna"
numbers = [6,7,8]
if check_data:
print ("Hello World" " " "Moorthi")
if check_sample:
print ("Hello Moorthi")
if check_value == False:
print ("I am in False")
elif check_value == True:
print ("I am in \n True")
else:
print ("Checking")
for char in letters:
print (char)
total=0
for num in numbers:
total = total + num
print ("Total : ",total)
for test in numbers:
pass
def krishnaMethod():
""" Documentation """
print ("I am inside method ",min(numbers))
krishnaMethod()
def greet(*names, msg = "Good morning!"):
"""
This function greets to
the person with the
provided message.
If message is not provided,
it defaults to "Good
morning!"
"""
for name in names:
print("Hello",name + ', ' + msg)
greet("Kate","krishna","Moorthi")
greet("Bruce",msg="How do you do?")
print("Pi Value : ",pi)
while True:
try:
validnumber=int(input("Please eneter number :"))
break
except:
print("Invalid data")
Output:
Hello World Moorthi Hello Moorthi I am in True H e l l o K r i s h n a Total : 6 Total : 13 Total : 21 I am inside method 6 Hello Kate, Good morning! Hello krishna, Good morning! Hello Moorthi, Good morning! Hello Bruce, How do you do? Pi Value : 3.141592653589793 Please eneter number : 3
No comments:
Post a Comment