Source Codes: Question No.1
Source Codes: Question No.1
Question no.1:
Question no.2:
Question no.3:
import math
def area_square(a):
area1=float(a*a);
print("Area of square is:",area1)
def area_circle(r):
area2=float(3.14*r*r);
print("Area of circle is:",area2)
def area_rectangle(a,b):
area3=float(a*b);
print("Area of rectangle is:",area3)
def area_triangle(x,y):
area4=float((x*y)/2);
print("Area of triangle is:",area4)
def peri_square(a):
peri1=float(4*a);
print("Perimeter of square is:",peri1)
def peri_circle(r):
peri2=float(2*3.14*r);
print("Perimter of circle is:",peri2)
def peri_triangle(a,b):
hypotenuse=float(math.sqrt(a*a+b*b))
peri3=float(a+b+hypotenuse)
print("Perimeter of right angled triangle is:",peri3)
def peri_rectangle(a,b):
peri4=float(2*(a+b))
print("Perimeter of rectangle is:",peri4)
side=float(input("enter the side of square:"))
area_square(side)
print()
peri_square(side)
radius=float(input("enter the radius of circle:"))
area_circle(radius)
peri_circle(radius)
length=float(input("enter the length of rectangle:"))
breadth=float(input("enter the breadth of rectangle:"))
area_rectangle(length,breadth)
peri_rectangle(length,breadth)
base=float(input("enter the base of right angled triangle:"))
height=float(input("enter the height of right angled triangle:"))
area_triangle(base,height)
peri_triangle(base,height)
Question no. 4:
Question no. 5:
Question no. 6:
Question no. 7:
income = float(input("Enter your monthly income here: "))
GST = 18
print("GST is",GST,"%")
tax = income - (income*GST/100)
print("The tax levied on your income is:",tax)
new_income = income - tax
print("Your new income is:",new_income)
Question no. 8:
lst = []
num = int(input('How many numbers: '))
for n in range(num):
numbers = int(input('Enter number '))
lst.append(numbers)
print("Maximum element in the list is :", max(lst), "\nMinimum element in the list
is :", min(lst))
Question no. 9:
lst = []
num = int(input('How many numbers:' ))
for n in range(num):
numbers = int(input("Enter number"))
lst.append(numbers)
lst.sort()
print("Second largest number in the list is:",sorted(lst)[-2])
print("Second smallest number in the list is:",sorted(lst)[-1])
Question no.10:
print("Multiples are:")
for a in range(1,n+1):
res = num*a
print(res)
Question 12:
String = input("Enter a string:")
Vowels = 0
For i in string:
if (i == 'a' or i == 'e' or i == 'i' or i=='u'):
vowels = vowels + 1
Print("Number of vowels in the string is:")
Print(vowels)
Question 13:
S = input("Enter any sentences:")
A = input("Enter any alphabet to find:")
Found = false
Words = s.split()
For word in words:
if word.startswith(a)
print(word)
found = true
if(found==false):
print("No word starting with user entered alphabet.")
Question 14:
Count = 0
My_string = input("Enter your word/sentence:")
My_char = input("Enter the alphabet:")
For i in my_string:
if i == my_char
count +=1
Question 16:
Students = dict()
N = 5
For i in range(n):
sname = input("Enter names of students:")
marks = []
for j in range(5):
mark = float(input("Enter marks:")
marks.append(mark)
students[sname] = marks
Print("Dictionary of student created:")
Question 17:
My_dict = {'x':500,'y':5874,'z':560}