You are on page 1of 2

BAI 1:

a = int(input())
b = int(input())
print('a+b= ', a+b)
print('a-b= ', a-b)
print('a*b= ', a*b)
print('a/b= ',a/b)
BAI 2:
a=int(input())
b=int(input())
print(-b/a)
BAI 3:
import math
a=float(input())
b=float(input())
c=float(input())
delta = b**2-4*a*c
if delta>0:
x1 = (-b-math.sqrt(delta))/(2*a)
x2 = (-b+math.sqrt(delta))/(2*a)
print('x1=',x1,'x2=',x2)
elif delta == 0:
x1 = -b/(2*a)
print('x1=x2=',x1)
else :
print('ptvn')
BAI 4:
a = [float(i) for i in input().split()]
dem=0
phu=0
for i in a:
phu=phu+i
dem= dem+1
print('TB= ',phu/dem)
if phu/dem <=5: print('tb')
elif phu/dem <8 and phu/dem>5: print('kha')
else: print('gioi')
BAI 5:
import math
#cv,dien tich hcn
dai = float(input('dai= '))
rong = float(input('rong= '))
cv = (dai+rong)*2
dt = dai*rong
print('chu vi hcn: ',cv)
print('dien tich hcn: ',dt)
#cv,dt hinh tron
r = float(input('r= '))
cvht = 2*r*math.pi
dtht = r**2*math.pi
print('chu vi hinh tron: ',cvht)
print('dien tich hinh tron: ',dtht)
#cv,dt tg
a = float(input('a'))
b = float(input('b'))
c = float(input('c'))
cvtg = a+b+c
p=(a+b+c)/2
s = math.sqrt(p*(p-a)*(p-b)*(p-c))
print('chu vi tam giac: ',cvtg)
print('dien tich tam giac: ',s)
BAI 6:
thang = int(input('thang: '))
nam = int(input('nam: '))
if thang==1 or thang==3 or thang==5 or thang==7 or thang==8 or thang==10 or
thang==12:
print('co 31 ngay')
elif thang == 4 or thang == 6 or thang==9 or thang==11:
print('co 30 ngay')
if thang==2:
if nam%400==0 or (nam%4==0 and nam%100!=0):
print('co 29 ngay')
else: print('co 28 ngay')

You might also like