We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
#Ql: Write a Python program which accept the radius of a circle from the user
ihnd compute the area.
import math
r=float (input ("Enter Radius:"))
print (math-pi)
area= [Link]
print ("Area of circle with radius #£ is $£" $(r,area))#02: Temperature of a city in Fahrenheit degrees is input through the keyboard.
gurite 2 program to convert this temperature into centigrade degrees
farsint (input ("Enter Temperature in Farenheit:"))
cel= (far - 32 )* (5/9)
print(" %.2£ Farenheit is %.3f in celsius"s(far,cel))#write a Python Program to make a simple calculator
#that can add, subtract, multiply and divide
while (True) +
asint (input ("Enter Pirst number :"))
nt (input ("Enter Second number :"))
print ("Please enter the operation you want to perform +, - , *, / :\n’
term=input ("Enter Choice
match term:
case "4":
res=a+b
print (a, texm,b,
res=a-b
print (a,term,b,
case ™
es=atb
print (a, term,b, "=", res)
case "/
resea/D
print (a, term,b, *
”
yres)
Fes)
", res)
print ("Invalid Operation entered")
exeinput ("Press q if you want to quic? ")
if ex == "gq" or ex == "quit
print ("Quiting Calculator")
break#04: Write a Python Program to calculate the square root
import math
a=float (input ("Enter number :"))
esemath. sqrt (a)
print ("Square root of 2.3f is #.3£"%(a,res))ffOS: Write a Python Program to Solve the quadratic equation ax**2 + bx + ¢
# Coeffients a, b and c are provided by the user
¥{Hint: import complex math medule - import cmath]
import cmath
Smport math
asint (input ("snter coefficent of x Square number:"))
bint (input ("Enter coefficent of x number:"))
c=int (input ("Enter Constant:"))
det= cmath. sqrt (pow(b,2)-4*a*c)
b+det) / (2*a)
-b-det) / (2*a)
print ("\n")
¥ come back to make it pretty
Sf (elimag == 0):
print ("First Solution:",[Link])
else:
print ("First solution:", x1)
Af (2,imag == 0):
print ("Second Solution: ",[Link])
else:
print ("second solution:", x2)
0#Q6: Write a Python Program to find the area of triangle
# Three sides of the triangle a, b and c are provided by the user
import math
a-float (input ("Enter First side:"))
befloat (input ("Enter Second Side:"))
c=float (input ("Enter Third Side:"))
#using Heron's Formula where a/b and c are the sides and s is the semi perimeter
s=(atbte) /2
areas math. aqrt (s*(3-a) * (sb) #(s-c))
print ("\nThe area of the traingle with sides d, $d and #d is 4.3£"8(a,b,c,area)#'g7: Write a Python program to print the following string in a specific format
Hwinkle twinkle little star
Twinkle, twinkle, littl star,
How I wonder what you are!
Up above the world so high,
Like a diamond in the sky.
Qwinkle, twinkle, little star,
How I yonder what you are
stri="Twinkle, twinkle, Little star, \n\t\
How I wonder what you are! \n\t\t\
Up above the world so high, \n\t\t\
Like a diamond in the sky.\n\
Twinkle, twinkle, little star,\n\t\
How I wonder what you are"
print (str1)#98: Write a Python program to display your details like
fname, age, address in three different lines.
inpat ("Eater Name!
age = input ("Enter age:")
pddress = input ("Enter address:*)
print ("\nName:%s\nAge:%s\nAddress:%s"% (name, age, address) )#99: If a five-digit number is input through the keyboard,
trite a program to calculate the sum of its digits without using any loop.
#(Hint: Use the modulus operator *%")
xeint (input ("Enter five digit number:"))
‘temp=x
di=x810
‘temp=temp//pow (19,1)
a2=tempel0
‘temp=temp//10
ag=tempe10
‘temp=temp//10
suml -dl+d2+d3+as+a5
print ("Phe sum of all the digits of sd is sd"§(x,suml))Enter Radius:2.12
3.141592653589793
Area of circle with radius 2.120000 is 14.119574enter Temperature in Farenheit:350
350.00 Farenheit is 176.667 in CelsiusEnter First number :23
enter Second number :221
Please enter the operation you want to perform +, - ,
enter Choice:+
23 4 221 = 264
Press q if you want to quit? q
Quiting calculatorEnter number :25.45
Square root of 25.450 is 5.045
yEnter coefficent of x Square number:3
Enter coefficent of x number:2
Enter Constant:1
First Solution: (-0.3333333333333333+0.47140452079103173})
Second Solution: (-0.3333333333333333-0.471404520791031733)
RESTART: C:\Users\ASUS\basic_python_ program\LAB EXCERCISE 1 5-3-24\Labl_a5-py
enter coefficent of x Square number:2
enter coefficent of x number:3
anter Constant:1
First solution: -0.5
second Solution: -1.0Enter First side:5.1
Enter Second Side
enter Third Side:2
The area of the traingle with sides 5, 4 and 2 is 3.707Twinkle, twinkle, little ster,
How I wonder what you are!
Up above the world so high,
Like a diamond in the sky.
Twinkle, twinkle, little star,
How I wonder what you are
:Enter Name:Ash
Enter Age:14
Enter Address:Universal
Address :UniversalEnter five digit number:54321
The sum of all the digits of 54321 is 15
i