0% found this document useful (0 votes)
5 views2 pages

Bai Tap

Uploaded by

Nguyễn Tuấn
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views2 pages

Bai Tap

Uploaded by

Nguyễn Tuấn
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Cau 1:

a,b = int(input("nhap hai so bat ki trong mot dong cach nhau bang 1 dau cach:
")).split()
print("tong cua hai so ",a," va ",b," la: ",a+b)
print("tich cua hai so ",a," va ",b," la: ",a*b)
cau 2:

a,b,c = int(input("nhap ba so nguyen duong a b c tren mot dong cach nhau bang
dau ,: ")).split(",")
while a < 0 or b <0 or c <0:
a,b,c = int(input("nhap lai ba so nguyen duong a b c tren mot dong cach nhau
bang dau ,: ")).split(",")
if a < c & b <c:
if a + b >= c:
print("dau la hinh tam giac")
if a == b == c:
print("day la tam giac deu")
elif a == c or a == b or b == c:
print("day la tam giac cam")
else:
print("day ko phai la tam giac")
elif b < a & c <a:
if c + b >= a:
print("dau la hinh tam giac")
if a == b == c:
print("day la tam giac deu")
elif a == c or a == b or b == c:
print("day la tam giac cam")
else:
print("day ko phai la tam giac")
elif a < b & c <b:
if c + a >= b:
print("dau la hinh tam giac")
if a == b == c:
print("day la tam giac deu")
elif a == c or a == b or b == c:
print("day la tam giac cam")
else:
print("day ko phai la tam giac")
cau 3:

import math
uoc=[]
so = int(input("nhap so tu nhien bat ki: "))
if so %2 == 0:
print("so do la so chan")
elif so %2 != 0:
print("so do la so le")
if so == 0:
print("so do la so 0")
elif so >0:
print("so do duong")
elif so < 0:
print("so do am")
if so == 1:
print("uoc cua cac so khong phai so ngto la: 1")
so1= abs(so)/2
so1=int(so1)
for i in range(1,so1+1,1):
if so %i ==0:
uoc.append(i)
if len(uoc) != 1:
print("uoc cua cac so khong phai so ngto la: ",uoc)

cau 4:

uoc = []
so= int(input("nhap mot so: "))
for i in range(1,so+1,1):
if so %i ==0:
uoc.append(i)
print("uoc cua so do la: ",uoc)
cau 6:

n = int(input("nhap so n bat ki: "))


while n <= 0:
n = int(input("nhap lai so n: "))
tong1 = 0
for i in range(1,n+1,1):
tong1 = tong1+ 1**2
tong2 = (n*(n+1)*(2*n+1))/6
if tong1 == tong2:
print("bthuc do dung")
else:
print("bieu thuc do sai")

cau 7:

ngto =[]
uoc= []
so = 100000
for i in range(1,so+1,1):
for n in range(1,i+1,1):
so1= n/2
so1=int(so1)
for d in range(1,so1+1,1):
if n %d ==0:
uoc.append(d)
if len(uoc) == 1:
ngto.append(n)
print("cac so ngto la:",ngto)

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy