self.Khoa = Khoa def getMSSVs elf: return self.MSSV def getHoTen self: return self.HoTen def getKhoas elf: return self.Khoa def setMSSVs elf,MSSV: self.MSSV = MSSV def setHoTens elf,HoTe
Trang 1n =
int(input("Nhap N: "))
dem =0 for i in range(1 ,n+1): print i if( i%2
== 0):
dem = dem +i print
"Tong
=", dem HDT.PY
class SinhVien: MSSV = '001' HoTen = 'Mai A' Khoa = '57'
def init (sel
f, MSSV, HoTen, Khoa):
self.MSSV
= MSSV
self.HoTen
= HoTen
Trang 2self.Khoa
= Khoa def getMSSV(s elf):
return self.MSSV def getHoTen( self):
return self.HoTen def getKhoa(s elf):
return self.Khoa def setMSSV(s elf,MSSV):
self.MSSV
= MSSV def setHoTen(s elf,HoTen):
self.HoTen
= HoTen
Trang 3def setKhoa(s elf, Khoa):
self.Khoa
=Khoa s=[] s.append( SinhVien(" 001", "Mai A", "57")) s.append( SinhVien(" 002",
"Tran B",
"58")) s.append( SinhVien(" 003", "Le C", "57")) s.append( SinhVien(" 004",
"Pham Q",
"58")) s.append( SinhVien(" 005",
"Nguyen N", "59")) for i in range(1 len(s)):
print(s[i].g etMSSV())
print(s[i].g etHoTen()) print(s[i].g
Trang 4etKhoa())
class KH:
MaKhoa = '56' TenKhoa = 'Khoa 56CNTT'
def init (sel
f, MaKhoa, TenKhoa):
self.MaKho
a = MaKhoa
self.TenKh
oa = TenKhoa
def getMaKho a(self):
return self.MaKho a
def getTenKho a(self):
return self.TenKh oa
Trang 5def setMaKhoa (self,MaKh oa):
self.MaKho
a = MaKhoa def setTenKho a(self, TenKhoa):
self.TenKh
oa = TenKhoa s=[] s.append( KH("56","K hoa 56CNTT")) s.append( KH("57","K hoa 57CNTT")) s.append( KH("58","K hoa 58CNTT")) s.append( KH("59","K hoa 59CNTT")) for i in range(1 len(s)): print(s[i].g etMaKhoa(
Trang 6))
print(s[i].g etTenKhoa ())
SOHOC.PY
"Nha
p A:
"
a
=
in
p
ut
()
p
ri
nt
"
N
h
a
p
B:
"
b
=
in
p
ut
()
p
ri
nt
"T
o
n
g
=
",
a
Trang 7+ b p ri nt
" Hi e
u
=
", a-b p ri nt
" Ti c
h
=
", a
* b p ri nt
" T h u o n
g
=
", a/ b p ri nt a
Trang 8% b p ri nt a
** b
SWAP.PY
"Nha pA:" a
=
i n p u t ( ) p ri n t
" N h a p B :
"
b
= i n
Trang 9p u t ( )
t
=
a a
=
b b
= t p ri n
t a , b