Python Programs
Python Programs
print("Hello, Python!")
$ python test.py
Hello, Python!
2. Write python program to store data in list and then try to print them.
#!/usr/bin/python
Output:
>>> count = 0
>>> while (count < len(places)):
print(places[count])
count = count+1
Output:
srinagar
kashmir
jammu
Output:
srinagar
kashmir
jammu
4. Write python program to let user enter some data in string and then verify data and
print welcome to user.
>>>str1=input("Enter string:")
str2='Hello'
if str1==str2:
print("Welcome")
else:
print("Not allowed")
5. Write python program in which a function is defined and calling that function prints
Hello World.
Function definition is here
>>> def printme():
print ('Hello World')
8. Write a python program in which a function is defined which checks whether a number
is even or odd.
>>>def check(no):
if (no%2==0):
print ("No. is EVEN ")
else:
print ("No. is ODD ")
check(5)
check(4)
Output:
No. is EVEN
No. is ODD
9. Write a python program to find area of a circle by taking value of radius as input from
the user.
>>>rad=input("Enter radius of circle:")
area=3.14*rad*rad
print(area)