Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

4/17/22, 12:03 PM Untitled42.

ipynb - Colaboratory

p;'
1)-

1
number = input("Enter a number ")

2
x = int(number)%2

3
if x == 0:

4
    print(" The number is Even ")

5
else:

6
    print(" The number is odd ")

2)-

1
import math

2
a = float(input("Enter the length of side a: "))

3
b = float(input("Enter the length of side b: "))

4
c = float(input("Enter the length of side c: "))

5
s = (a+b+c)/2

6
area = math.sqrt(s*(s-a)*(s-b)*(s-c))

7
print(" Area of the triangle is: ", area)

3)-

1 import math
2 r = float(input("Input the radius of the circle: "))
3 c = 2 * math.pi * r
4 area = math.pi * r * r
5 print("The circumference of the circle is: ", c)
6 print("The area of the circle is: ", area)

4)-

1 number = int(input("Enter an integer: "))
2 if(number%5==0):
3     print(number, "is a multile of 5")
4 else:
5     print(number, "is not a multiple of 5")

5)-

1 import math
2 a = float(input("Enter the first coefficient: "))
3 b = float(input("Enter the second coefficient: "))
4 c = float(input("Enter the third coefficient: "))
https://colab.research.google.com/drive/1_g43pFin-Y3owdCDz3RcZCEd7tpdGxdZ#scrollTo=gnEiN6EsjCX0&printMode=true 1/3
4/17/22, 12:03 PM Untitled42.ipynb - Colaboratory
( p ( ))
5 if (a!=0.0):
6     d = (b*b)-(4*a*c) 
7     if (d==0.0):
8         print("The roots are real and equal.") 
9         r = -b/(2*a)
10         print("The roots are ", r,"and", r)
11     elif(d>0.0):
12         print("The roots are real and distinct.")
13         r1 = (-b+(math.sqrt(d)))/(2*a) 
14         r2 = (-b-(math.sqrt(d)))/(2*a)
15         print("The root1 is: ", r1)
16         print("The root2 is: ", r2)
17     else:
18         print("The roots are imaginary.")
19         rp = -b/(2*a)
20         ip = math.sqrt(-d)/(2*a)
21         print("The root1 is: ", rp, "+ i",ip)
22         print("The root2 is: ", rp, "- i",ip)
23 else:
24     print("Not a quadratic equation.")

6)-

1 numbers = [3,4,1,9,6,2,8]
2 print(numbers)
3 x = int(input("Enter the number to be inserted: "))
4 y = int(input("Enter the position: "))
5 numbers.insert(y,x)
6 print(numbers)

https://colab.research.google.com/drive/1_g43pFin-Y3owdCDz3RcZCEd7tpdGxdZ#scrollTo=gnEiN6EsjCX0&printMode=true 2/3
4/17/22, 12:03 PM Untitled42.ipynb - Colaboratory

check 5s completed at 12:39 AM

https://colab.research.google.com/drive/1_g43pFin-Y3owdCDz3RcZCEd7tpdGxdZ#scrollTo=gnEiN6EsjCX0&printMode=true 3/3

You might also like