Python Lab1
Python Lab1
INPUT
import math
r= int(input("radius of circle"))
A = math.pi*(r)**2
OUTPUT:
radius of circle7
Q2
import math
y= (x-32)/1.8
OUTPUT:
Q3:
#Q3: Write a Python Program to make a simple calculator that can add, subtract, multiply and divide
print("TO ADD")
x+y
print ("addition of two numbers: x+y=", x+y)
print("TO SUBSTRACT")
a-b
print("TO MULTIPLY")
c*d
print("TO DEVIDE")
m/n
OUTPUT:
TO ADD
TO SUBSTRACT
TO MULTIPLY
TO DEVIDE
Enter first number:64
Q4:
import math
x= math.sqrt(y)
print(x)
OUTPUT:
enter number25
5.0
Q5:
a= int(input("a="))
b= int(input("b="))
c= int(input("c="))
d=(b**2)-(4*a*c)
import math
#Solution
x1=(-b- math.sqrt(d))/(2*a)
x2=(-b+ math.sqrt(d))/(2*a)
print("solution are",x1,x2)
OUTPUT:
a=1
b=5
c=6
Q6:
a= int(input("a="))
b= int(input("b="))
c= int(input("c="))
s=(1/2)*(a+b+c)
import math
A=math.sqrt(s*(s-a)*(s-b)*(s-c))
OUTPUT:
a=4
b=6
c=8
#Q7: If a five-digit number is input through the keyboard, write a program to calculate the sum
#of its digits without using any loop. (Hint: Use the modulus operator ‘%
sum=0
n= int(input("num="))
x1= n%10
sum=sum+x1
n= n//10
x2= n%10
sum=sum+x2
n= n//10
x3= n%10
sum=sum+x3
n= n//10
x4= n%10
sum=sum+x4
n= n//10
x5= n%10
sum=sum+x5
print("Addition of number=",sum)
OUTPUT:
num=12345
Addition of number= 15
#Q8: Write a Python program to print the following string in a specific format
OUTPUT:
Q9:
#Q9:Write a Python program to display your details like name, age, address in three different lines.
Age:22\n\
OUTPUT:
Age:22