2. Python program to check whether the given
number is even or not.
number = input("Enter a number: ")
x = int(number)%2
if x == 0:
print("The number is Even.")
else:
print("The number is Odd.")
Output:
Enter a number: 7
The number is Odd.
Enter a number: 6
The number is Even.
3. Python program to convert the temperature
in degree centigrade to Fahrenheit
Output:
c = input("Enter temperature in
Centigrade: ")
f = (9*(int(c))/5)+32
print("Temperature in Fahrenheit is: ", f)
Enter temperature in Centigrade: 30
Temperature in Fahrenheit is: 86.0
4. Python program to find out the average of a set
of integers
Output:
count = int(input("Enter the count of numbers: "))
i = 0
sum = 0
for i in range(count):
x = int(input("Enter an integer: "))
sum = sum + x
avg = sum/count
print("The average is: ", avg)
Enter the count of numbers: 5
Enter an integer: 3
Enter an integer: 6
Enter an integer: 8
Enter an integer: 5
Enter an integer: 7
The average is: 5.8
5. Python program to find the circumference
and area of a circle with a given radius
Output:
r = float(input("Input the radius of the circle: "))
c = 2 * 3.14 * r
area = 3.14 * r * r
print("The circumference of the circle is: ", c)
print("The area of the circle is: ", area)
Input the radius of the circle: 7
The circumference of the circle is: 43.96
The area of the circle is: 153.86
6. Python program to check whether the given
integer is a multiple of both 5 and 7
Output:
number = int(input("Enter an integer: "))
if((number%5==0)and(number%7==0)):
print(number, "is a multiple of both 5 and 7")
else:
print(number, "is not a multiple of both 5 and 7")
Enter an integer: 33
33 is not a multiple of both 5 and 7
7. Python program to display the given integer
in a reverse manner
Output:
number = int(input("Enter a positive integer: "))
rev = 0
while(number!=0):
digit = number%10
rev = (rev*10)+digit
number = number//10
print(rev)
Enter a positive integer: 739
937
8. Python program to implement linear search
Output:
numbers = [4,2,7,1,8,3,6]
f = 0 #flag
x = int(input("Enter the number to be found out: "))
for i in range(len(numbers)):
if (x==numbers[i]):
print("Successful search, the element is found at position", i)
f = 1
break
if(f==0):
print("Oops! Search unsuccessful")
Enter the number to be found out: 7
Successful search, the element is found at position 2
9. Python Program to Find the Sum of all the
elements of a list
Output:
List=[2,6,12,8,32,17,15]
Sum = 0
for i in List:
Sum=Sum+i
print("The sum of the list elements =",Sum)
The sum of the list elements = 92
10. Program to accessing elements of a list using
loops
a= [32,55,7,12,65,32,90,27,12]
for i in a:
print(i)
Output
32
55
7
12
65
32
90
27
12 10
11. Program to generate a list of 10 even numbers
List=[]
for i in range(2,21,2):
List.append(i)
print(List)
Output
[2, 4, 6, 8, 10, 12, 14, 16, 18, 20]