1 To find the square of the number entered from the user end.
num = int(input("Enter a number: "))
square = num * num
print(square)
2 To find the sum of two numbers entered from the user end.
a = int(input("Enter first number: "))
b = int(input("Enter second number: "))
sum = a + b
print(sum)
3 To convert length in kilometre entered by user into metres.
km = float(input("Enter length in kilometre: "))
metre = km * 1000
print(metre)
4 To print the table of any number entered by the user up to five terms.
num = int(input("Enter a number: "))
for i in range(1, 6):
print(num, "x", i, "=", num * i)
5 To calculate Simple Interest, Si= (p*r*t)/100 where p, r, t has to be taken from user end.
p = float(input("Enter principal: "))
r = float(input("Enter rate: "))
t = float(input("Enter time: "))
si = (p * r * t) / 100
print(si)
6 To calculate the average marks of 3 subjects.
m1 = float(input("Enter marks of subject 1: "))
m2 = float(input("Enter marks of subject 2: "))
m3 = float(input("Enter marks of subject 3: "))
average = (m1 + m2 + m3) / 3
print(average)
7 To calculate the area of a triangle with base and height.
base = float(input("Enter base: "))
height = float(input("Enter height: "))
area = 0.5 * base * height
print(area)
8 To calculate surface area and volume of a cuboid.
l = float(input("Enter length: "))
b = float(input("Enter breadth: "))
h = float(input("Enter height: "))
surface_area = 2 * (l*b + b*h + l*h)
volume = l * b * h
print(surface_area)
print(volume)
9 Write a program in python to check whether the given character is vowel or consonant.
ch = input("Enter a character: ").lower()
if ch == 'a' or ch == 'e' or ch == 'i' or ch == 'o' or ch == 'u':
print("Vowel")
else:
print("Consonant")
11 Write a program in python to find the largest number among the three input numbers.
a = int(input("Enter first number: "))
b = int(input("Enter second number: "))
c = int(input("Enter third number: "))
if a > b and a > c:
print(a)
elif b > a and b > c:
print(b)
else:
print(c)
12 Write a program to find those numbers which are divisible by 7 and multiple of 5 between
1600 and 2800 (Both included).
for i in range(1600, 2801):
if i % 7 == 0 and i % 5 == 0:
print(i)
13 Write a program to display 10 natural numbers in reverse order.
for i in range(10, 0, -1):
print(i)
14 To print the first 10 even numbers.
for i in range(1, 21):
if i % 2 == 0:
print(i)
15 To print the sum of the first 10 natural numbers.
sum = 0
for i in range(1, 11):
sum = sum + i
print(sum)
16 To find the sum of squares of the first 100 natural numbers.
sum = 0
for i in range(1, 101):
sum = sum + i * i
print(sum)
17 Create a list in python of children selected for a maths quiz with the following names:
Anaya, Raj, Rohit, Isha, Kartik, Sonal, Preet.
children = ["Anaya", "Raj", "Rohit", "Isha", "Kartik", "Sonal", "Preet"]
print(children)
[Link]("Isha")
[Link]("Jay")
[Link](1)
print(children)
18 Create a list num=[23, 34, 45, 56, 67, 78]
num = [23, 34, 45, 56, 67, 78]
print(len(num))
print(num[1:4])
print(num[-4:-1])
19 WAP to create a list l1=[23, 24,25,26,27,28,29,30] if the element is odd add 5 and if it is
even add 10 and print the final list.
l1 = [23,24,25,26,27,28,29,30]
new_list = []
for i in l1:
if i % 2 == 0:
new_list.append(i + 10)
else:
new_list.append(i + 5)
print(new_list)
20 WAP to delete all odd numbers and negative numbers in a given list.
L1 = [11, -1, -22, -3, 33, 55, 44, -50, 46, 101]
new = []
for i in L1:
if i > 0 and i % 2 == 0:
[Link](i)
print(new)
21 Write a program that displays all the odd numbers [7, 10, 12, 16, 5, 2] in the given list.
lst = [7, 10, 12, 16, 5, 2]
for i in lst:
if i % 2 != 0:
print(i)
22 L1=[20,30,40,50,[“HI”, “Python”, “Platform”], 60,70,80]] Find the output of the following:
L1 = [20,30,40,50,["HI","Python","Platform"],60,70,80]
print(L1[4])
print(L1[0:4])
print(L1[4][2])
print(L1[4][2][3:6])
23 Create a list of the first 10 even numbers, add 1 to each list items, and print the final list.
lst = []
for i in range(1, 21):
if i % 2 == 0:
[Link](i)
for i in range(len(lst)):
lst[i] = lst[i] + 1
print(lst)
24 Create a list L1=[10, 20, 30, 40]. Add the elements [14, 12, 15] using the extend function.
Now sort the final list in ascending order and print it.
L1 = [10, 20, 30, 40]
[Link]([14, 12, 15])
[Link]()
print(L1)
25 WAP to find min and max elements in the list entered by the user.
lst = list(map(int, input("Enter numbers: ").split()))
print(min(lst))
print(max(lst))