Bài 1
a, b=map(int, input().split())
tong=a+b
hieu=a-b
tich=a*b
thuong= round(a/b,2) if b!=0 else "b=0"
du=a%b
nguyen=a//b if b!=0 else "b=0"
print(f"{tong} {hieu} {tich} {thuong} {du} {nguyen}")
Bài 2
n=int(input())
kq=(n-1)*(n+1)
print(f"{kq}")
Bài 3
x=float(input())
nguyen=int(x)
le=x-nguyen
print(f"{nguyen} {le:.2f}")
Bài 4
dx, n=input().split()
x=float(x)
n=int(n)
s=x*(x**n-1)/(x-1)
print(f"{s:.4f}")
Bài 5
import math
x=float(input())
f=math.sqrt(x**2+4*x+4)-math.sqrt(x**2)
print(f"{f:.1f}")
Bài 6
s=input()
s1=s[::-1]
n=len(s.split())
s3=s.title()
s4=s.upper()
print(f"{s1}\n{n}\n{s3}\n{s4}")
Bài 7
p, q=map(int,input().split())
b=p+q
c=p*q
print(f"x**2 + {b}x + {c} =0")
Bài 8
m, n, a=map(int,input().split())
tt=m*n*a
print(f"{tt}")
Bài 9
import math
a, b, c= map(int,input().split())
uc2=math.gcd(a,b)
uc3=math.gcd(uc2,c)
bc2=a*b//uc2
bc3=c*bc2//uc3
print(f"{uc3} {bc3}")
Bài 10
Tags:
Python Cơ bản THCS
tuan n=int(input("nhập n:"))
k=int(input("nhập k:"))
tong=n+k
hieu=n-k
tich=n*k
thuong=n/k
print(f"{tong} {hieu} {tich} {thuong}")
hân b1 n=int(input("nhập n:"))
k=int(input("nhập k:"))
tong=n+k
hieu=n-k
tich=n*k
nguyen=n//k
du=n%k
print(f"tổng là{tong}")
print(f"hiệu là{hieu}")
print(f"phần nguyên{nguyen}")
print(f"phần dư{du}")
trâm anh b1
n=int(input("nhập n:"))
k=int(input("nhập k:"))
tong=n+k
hieu=n-k
tich=n*k
nguyen=n//k
du=n%k
print(f"tổng là {tong}")
print(f"hiệu là{hieu}")
print(f"tích là{tich}")
print(f"phần nguyên {nguyen}")
print(f"phần dư {du}")
n=int(input("nhập n:"))
k=int(input("nhập k:"))
tong=n+k
hieu=n-k
tich=n*k
nguyen=n//k
du=n%k
print(f"tổng là {tong}")
print(f"Hiệu là {hieu}")
print(f"Tích là {tich}")
print(f"Phần nguyên là {nguyen}")
print(f"Phần dưlà {du}")
hân b1 n=int(input("nhập n:"))
k=int(input("nhập k:"))
tong=n+k
hieu=n-k
tich=n*k
nguyen=n//k
du=n%k
print(f"tổng là{tong}")
print(f"hiệu là{hieu}")
print(f"tích là{tich}")
print(f"phần nguyên{nguyen}")
print(f"phần dư{du}")
đào n=int(input("nhập n:"))
k=int(input("nhập k:"))
tong=n+k
hieu=n-k
tich=n*k
nguyen=n//k
du=n%k
print(f"Tổng là {tong}")
print(f"Hiệu là {hieu}")
print(f"Tích là {tich}")
print(f"phần nguyên {nguyen}")
print(f"phần dư {du}")
tuan n=int(input("nhập n:"))
k=int(input("nhập k:"))
tong=n+k
hieu=n-k
tich=n*k
nguyen=n//k
du=n%k
print(f" tổng là {tong}")
print(f" hiệu là {hieu}")
print(f" tích là {tich}")
print(f" phần nguyen {nguyen}")
print(f" phần dư {du}")
trâm anh b2
n=int(input("nhập n:"))
tich=(n-1)*(n+1)
print(f"tich là:{tich}")
tuan n=int(input("nhập n:"))
tich=(n-1)*(n+1)
print(f"tích là:{tich}")
đàon=int(input("Nhập n"))
tich=(n-1)*(n+1)
print(f"Tích là:{tich}")
hân b2 n=int(input("nhập n"))
tich=(n-1)*(n+1)
print(f"tích là :{tich}")
hao b2 N=int(input("nhập n"))
tich=(n-1)*(n+1)
print(f"tích là: {tich}")
tuan x=float(input("nhâp x:"))
ng=int(x)
le=x-ng
print(f"phần nguyên {ng}")
print(f"phần lẻ {le:.2f}")
hao b3 x=float(input("nhập x:"))
ng=int(x)
le=x-ng
print(f"phần nguyên {ng}")
print(f"phần lẻ {le:.2f}")
hân b3 x=float(input("nhập x:"))
ng=int(x)
le=x-ng
print(f"phần nguyên {ng}")
print(f" phần lẻ {le:.2f}")
trâm anh b3
x=float(input("nhập x:"))
ng=int(x)
le=x-ng
print(f"phần nguyên {ng}")
print(f"phần lẻ {le:.2f}")
đào x=float(input("Nhập x:"))
ng=int(x)
le=x-ng
print(f"phần nguyên {ng}")
print(f"phần lẻ {le:.2f}")
%Run -c $EDITOR_CONTENT
Nhập x:2.5
phần nguyên 2
phần lẻ 0.50
>>>
tuan x=float(input("nhập x:"))
n=int(input("nhập n:"))
s=x*(x**n-1)/(x-1)
print(f" tổng là {s:.2f}")
hao b4 x=float(input("nhập x:"))
n=int(input("nhập n:"))
s=x*(x**n-1)/(x-1)
print(f"Tổng là {s:2f}")
trâm anh b4
x=float(input("nhập x:"))
n=int(input("nhập n:"))
s=x*(x**n-1)/(x-1)
print(f"tổng là {s:.2f}")
đào x=float(input("Nhập x:"))
n=int(input("Nhập n:"))
s=x*(x**n-1)/(x-1)
print(f"Tổng là {s:.2f}")
>>> %Run -c $EDITOR_CONTENT
Nhập x:2.5
Nhập n:3
Tổng là 24.38
>>>
trâm anh b5
import math
x=float(input("nhập x:"))
f=math.sqrt(x**2+4*x+4)-math.sqrt(x**2)
print(f"giá trị biểu thức là {f:.2f}")
đàoimport math
x=float(input("Nhập x:"))
f=math.sqrt(x**2+4*x+4)-math.sqrt(x**2)
print(f"Gía trị biểu thức là {f:.2f}")
>>> %Run -c $EDITOR_CONTENT
Nhập x:0.5
Gía trị biểu thức là 2.00
>>>
hân b5 import math
x=float(input("nhập x:"))
f=math.sqrt(x**2+4*x+4)-math.sqrt(x**2)
print(f"giá trị biểu thức là{f:.2f}")
hao b5 import math
x= float(input("nhập x:"))
f= math.sqrt(x**2+4*x+4)-math.sprt(x**2)
print(f"Giá trị biểu thức là {f:.2f}")
yenn=int(input("nhập n:"))
k=int(input("nhập k:"))
tong=n+k
hieu=n-k
tich=n*k
nguyen=n//k
du=n%k
print(f"tổng là{tong}")
print(f"hiệu là{hieu}")
print(f"phần nguyên{nguyen}")
print(f"phần dư{du}")
hân b6 s=input("nhập s")
s1=s[::-1]
s2=len(s.split())
s3=s.title()
s4=s=s.upper()
print(s1)
print(s2)
print(s3)
print(s4)
đàos=input("Nhập s:")
s1=s[::-1]
s2=len(s.split())
s3=s.title()
s4=s.upper()
print(s1)
print(s2)
print(s3)
print(s4)
>>> %Run -c $EDITOR_CONTENT
Nhập s:tin học
cọh nit
2
Tin Học
TIN HỌC
>>>
yenn=int(input("nhập n"))
tich=(n-1)*(n+1)
print(f"tích là :{tich}")
trâm anh b6
s=input("nhập s:")
s1=s[::-1]
s2=len(s.split())
s3=s.title()
s4=s.upper()
print(s1)
print(s2)
print(s3)
print(s4)
yenx=float(input("nhập x:"))
ng=int(x)
le=x-ng
print(f"phần nguyên {ng}")
print(f" phần lẻ {le:.2f}")
yenx=float(input("nhập x:"))
n=int(input("nhập n:"))
s=x*(x**n-1)/(x-1)
print(f"Tổng là {s:2f}")
yenimport math
x=float(input("nhập x:"))
f=math.sqrt(x**2+4*x+4)-math.sqrt(x**2)
print(f"giá trị biểu thức là{f:.2f}")
yenp=float(input("nhập p:"))
q=float(input("nhập q:"))
b=p+q
c=p*q
print(f"x**2+{b}x+{c}=o")
đào p=float(input("Nhập p"))
q=float(input("Nhập q"))
b=p+q
c=p*q
print(f"x**2+{b}x+{c}=0")>>> %Run -c $EDITOR_CONTENT
Nhập p 23
Nhập q 23
x**2+46.0x+529.0=0
>>>
trâm anh b7
p=float(input("nhập p:"))
q=float(input("nhập q:"))
b=p+q
c=p*q
print(f"x**2+{b}x+{c}=o")
trâm anh b9
import math
a=int(input("nhập a:"))
b=int(input("nhập b:"))
c=int(input("nhập c:"))
uc2=math.gcd(a,b)
uc3=math.gcd(uc2,c)
bc2=a*b/uc2
bc3=c*bc2/uc3
print(f"ươc chung a,b,c{uc3}")
print(f"bội chung a,b,c{bc3}")
yenb8import math
a=int(input("nhập a:"))
b=int(input("nhập b:"))
c=int(input("nhập c:"))
uc2=math.gcd(a,b)
uc3=math.gcd(uc2,c)
bc2=a*b/uc2
bc3=c*bc2/uc3
print(f"ước chung a,b,c {uc3}")
print(f"bội chung a,b,c {bc3}")
hân b9 s=input("nhập s")
s1=s[::-1]
s2=len(s.split())
s3=s.title()
s4=s=s.upper()
print(s1)
print(s2)
print(s3)
print(s4)
yến b8 m=int(input("nhập m :"))
n=int(input("nhập n :"))
a=int(input("nhập a:"))
tt=m*n*a
print(f"thành tiền{tt}")
hảo s=input("nhập s:")
s1=s[::-1]
s2=len(s.split())
s3=s.title()
s4=s.upper()
print(s1)
print(s2)
print(3)
print(4)
hảop=float(input("nhập p:"))
q=float(input("nhập q:"))
b= p+q
c= p+q
print(f"x**2+{b}x+{c}=0")
hảo import math
a=int(input("nhập a:"))
b=int(input("nhập b:"))
c=int(input("nhập c:"))
uc2= math.gcd(a,b)
uc3= math.gcd(uc2,c)
bc2=a*b/uc2
bc3=c*bc2/uc3
print(f" ước chung a,b,c {uc3}")
print(f"bội chung a,b,c {bc3}")
hân b2 a=int(input("nhập a:"))
b=int(input("nhập b:"))
if a%b==0:
print("{a} chia hết{b}")
else:
print("{a} không chia hết cho {b}")
hân b3 n=int(input("nhập năm:"))
if(n%4==0 and n% 100!=0)or n%400==o:
print(f"{n} là năm nhuận")
else:
print(f"{n} không phải năm nhuận")
hân b4 a=int(input("nhập a:"))
b=int(input("nhập b:"))
c=int(input("nhập c:"))
d=int(input("nhập d:"))
max=a
if max<c:
max=c
if max<d:
max=d
print(f"{max} là số lớn nhất")
hân b5 import math
n=int(input("nhập n:"))
can=math.isqrt(n)
if can*can==n:
print(f"{n} là số chính phương")
else:
print(f"{n} không phải số chính phương")
HÂN B6 def ngto(n):
if n<2:
return False
if n==2:
return True
for i in range (2,n):
if n%i==0:
return False
return True
n=int(input("nhập n:"))
if ngto(n):
print(f"{n} là số ngto")
else:
print(f"{n} không ngto")
uyen b1
n,k=map(int,input().split())
tong=n+k
hieu=n-k
tich=n*k
thuong=round(n/k,2) if k!=0 else "k=0"
du=n%k
nguyen=n//k if k!=0 else "k=0"
print(f"{tong} {hieu} {tich} {thuong} {du} {nguyen}")
uyen b2
n=int(input())
kq=(n-1)*(n+1)
print(f"{kq}")
uyen b3
x=float(input())
nguyen=int(x)
le=x-nguyen
print(f"{nguyen} {le:.2f}")
uyen b4
x,n=input().split()
x=float(x)
n=int(n)
s=x*(x**n-1)/(x-1)
print(f"{s:.4f}")
uyen b5
import math
x=float(input())
f=math.sqrt(x**2+4*x+4)-math.sqrt(x**2)
print(f"{f:.1f}")
uyen b6
s=input()
s1=s[::-1]
n=len(s.split())
s3=s.title()
s4=s.upper()
print(f"{s1} {n}")
print(f"{n}")
print(f"{s3}")
print(f"{s4}")
uyen b7
p,q=map(int,input().split())
b=p+q
c=p*q
print(f"x**2+{b}x+{c}=0")
uyen b8
m,n,a=map(int,input().split())
tt=m*n*a
print(f"{tt}")
uyen b9
import math
a,b,c=map(int,input().split())
ucln=math.gcd(a,b,c)
bcnn=a*b/ucln
bcnn1=c*bcnn/ucln
print(f"{ucln} {bcnn1:.0f}")