From c24f67edf44a287269f8fb08f40e85010c5bab01 Mon Sep 17 00:00:00 2001 From: FailFudhayl Date: Sat, 29 Oct 2022 14:01:06 +0800 Subject: [PATCH 1/4] seventh commit --- H071221026/Tugas Praktikum 7/no1.py | 12 ++++++++++++ H071221026/Tugas Praktikum 7/no2.py | 20 ++++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 H071221026/Tugas Praktikum 7/no1.py create mode 100644 H071221026/Tugas Praktikum 7/no2.py diff --git a/H071221026/Tugas Praktikum 7/no1.py b/H071221026/Tugas Praktikum 7/no1.py new file mode 100644 index 0000000..e43b52e --- /dev/null +++ b/H071221026/Tugas Praktikum 7/no1.py @@ -0,0 +1,12 @@ +import re +s= input() +if len(s)==45 : + pola1= r"(\A([A-Za-z02468]){40})[\s13579]{5}" + result1= re.match(pola1, s) + if result1 : + print("true") + else : + print("false") +else : + print("false") + diff --git a/H071221026/Tugas Praktikum 7/no2.py b/H071221026/Tugas Praktikum 7/no2.py new file mode 100644 index 0000000..6513fb7 --- /dev/null +++ b/H071221026/Tugas Praktikum 7/no2.py @@ -0,0 +1,20 @@ +import re +n= int(input('masukkan jumlah baris : ')) +listip= [] +for i in range(n) : + ip= input("Masukkan IP : ") + listip.append(ip) + +ipv4= r'(([0-1]?([\d]?){2}|2[0-4][\d]|25[0-5])\.){3}([0-1]?[\d][\d]?|2[0-4][\d]|25[0-5])$' +ipv6= r'(([\dA-Fa-f]{1,4}?\:){7})([\d,A-F,a-f]{1,4})$' + +for j in listip : + reasult1= re.match(ipv4, j) + if reasult1 : + print("IPv4") + else : + reasult2= re.match(ipv6, j) + if reasult2 : + print("IPv6") + else : + print("Bukan IP Address") \ No newline at end of file From b01c5648757f9dc42fb168d5a3659d86b02fe088 Mon Sep 17 00:00:00 2001 From: FailFudhayl Date: Sun, 6 Nov 2022 10:35:22 +0800 Subject: [PATCH 2/4] eighth commit --- H071221026/Tugas Praktikum 8/no1.py | 36 +++++++++++++++++++++++++++++ H071221026/Tugas Praktikum 8/no2.py | 32 +++++++++++++++++++++++++ 2 files changed, 68 insertions(+) create mode 100644 H071221026/Tugas Praktikum 8/no1.py create mode 100644 H071221026/Tugas Praktikum 8/no2.py diff --git a/H071221026/Tugas Praktikum 8/no1.py b/H071221026/Tugas Praktikum 8/no1.py new file mode 100644 index 0000000..784d5a3 --- /dev/null +++ b/H071221026/Tugas Praktikum 8/no1.py @@ -0,0 +1,36 @@ +class person : + def __init__(self, nama, umur, gender, hobi) : + self.name= nama + self.age= umur + self.isMale= gender + self.hobbies= hobi + + def setAge(self, umur) : + self.age= umur + def getAge(self) : + print(f"Umur : {self.age}") + + def setName(self, nama) : + self.name= nama + def getName(self) : + print(f"Nama : {self.name}") + + def setGender(self, gender) : + self.isMale= gender + def getGender(self) : + if self.isMale== True : + print("gendernya laki-laki") + else : + self.isMale== False + print("gendernya bukan laki-laki") + + def setHobi(self, hobi) : + self.hobbies= hobi + def getHobi(self) : + print(f"Hobi {self.name} asalah : {self.hobbies}") + +alex= person("alex", 22, True, "Belajar") +alex.getName() +alex.getAge() +alex.getGender() +alex.getHobi() \ No newline at end of file diff --git a/H071221026/Tugas Praktikum 8/no2.py b/H071221026/Tugas Praktikum 8/no2.py new file mode 100644 index 0000000..5c91329 --- /dev/null +++ b/H071221026/Tugas Praktikum 8/no2.py @@ -0,0 +1,32 @@ +lebar = float(input()) +tinggi = float(input()) +panjang = float(input()) +massa = float(input()) + +class BALOK : + def __init__(self, lebar, tinggi, panjang) : + self.wide= lebar + self.height= tinggi + self.long= panjang + def setLebar(self, lebar) : + self.wide= lebar + def setTinggi(self, tinggi) : + self.long= tinggi + def setPanjang(self, panjang) : + self.long= panjang + def setMassa(self, massa) : + self.weiht= massa + def getMassaJenis(self) : + return self.weiht/(self.long*self.wide*self.height) + +kubus = BALOK(lebar, tinggi, panjang) +kubus.setLebar(24) +kubus.setTinggi(50) +kubus.setPanjang(98) +kubus.setMassa(massa) +print("Massa Jenis =", kubus.getMassaJenis()) +kubus.setMassa(massa*2) +print("Massa Jenis =", kubus.getMassaJenis()) +kubus.setLebar(lebar) +print("Massa Jenis =", kubus.getMassaJenis()) + From ff6e47195be99b544a7ff9cbe6619537cf389d33 Mon Sep 17 00:00:00 2001 From: FailFudhayl Date: Sat, 12 Nov 2022 12:47:24 +0800 Subject: [PATCH 3/4] ninth commit --- H071221026/Tugas Praktikum 9/Hero.py | 97 ++++++++++++++++++++++++++++ H071221026/Tugas Praktikum 9/soal.py | 17 +++++ 2 files changed, 114 insertions(+) create mode 100644 H071221026/Tugas Praktikum 9/Hero.py create mode 100644 H071221026/Tugas Praktikum 9/soal.py diff --git a/H071221026/Tugas Praktikum 9/Hero.py b/H071221026/Tugas Praktikum 9/Hero.py new file mode 100644 index 0000000..f116109 --- /dev/null +++ b/H071221026/Tugas Praktikum 9/Hero.py @@ -0,0 +1,97 @@ +class Human: + def __init__(self, name, pos_x): + self.nama = name + self.__posisi = pos_x + + def setName(self, name): + self.nama = name + + def getName(self): + return self.nama + + def setMovement(self, arah): + if arah == 'L': + self.__posisi = self.__posisi - self._speed + elif arah == "R": + self.__posisi = self.__posisi + self._speed + + def getMovement(self): + return self.__posisi + + +class Hero(Human): + def __init__(self, name, pos_x): + super().__init__(name, pos_x) + self._power = 15 + self._health = 400 + self._armor = 15 + self._speed = 3 + + def attack(self, target): + target._health = target._health - self._power + + def setPower(self, power): + self._power = power + + def getPower(self): + return self._power + + def setHealth(self, health): + self._health = health + + def getHealth(self): + return self._health + + def setArmor(self, armor): + self._armor = armor + + def getArmor(self): + return self._armor + + def setSpeed(self, speed): + self._speed = speed + + def getSpeed(self): + return self._speed + + +class Warrior(Hero): + def __init__(self, name, pos_x): + super().__init__(name, pos_x) + self._power = 26 + self._armor = 30 + + def special(self, target): + self._armor = 45 + self._power = 32 + target._health = target._health - self._power + + +class Assassin(Hero): + def __init__(self, name, pos_x): + super().__init__(name, pos_x) + self._power = 35 + self.speed = 4 + + def getSpeed(self): + return self.speed + + def special(self, target): + self.speed = 7 + self._power = 42 + target._health = target._health - self._power + + +class Support(Hero): + def __init__(self, name, pos_x): + super().__init__(name, pos_x) + self._health = 500 + self._armor = 8 + self.speed = 4 + + def getSpeed(self): + return self.speed + + def special(self, target): + self.speed = 6 + target._health = target._health+150 diff --git a/H071221026/Tugas Praktikum 9/soal.py b/H071221026/Tugas Praktikum 9/soal.py new file mode 100644 index 0000000..b86c035 --- /dev/null +++ b/H071221026/Tugas Praktikum 9/soal.py @@ -0,0 +1,17 @@ +from Hero import Warrior, Assassin, Support +warrior = Warrior("bambang", pos_x=10) +assassin = Assassin("joko", pos_x=25) +support = Support("udin", pos_x=30) +# sebelum +print("health (before)", warrior.getHealth()) +assassin.attack(warrior) +# sesudah +print("health (after)", warrior.getHealth()) +print("-"*10) +# sebelum +print("Warrior (health)", warrior.getHealth()) +print("Support (speed) : ", support.getSpeed()) +support.special(warrior) +# sesudah +print("Warrior (health)", warrior.getHealth()) +print("Support (speed): ", support.getSpeed()) From e5e981edad8f9599869351019b840d9b1cc22f8a Mon Sep 17 00:00:00 2001 From: FailFudhayl Date: Fri, 25 Nov 2022 19:30:45 +0800 Subject: [PATCH 4/4] tenth commit --- H071221026/Tugas Praktikum 10/no1.py | 112 ++++++++++++++++++ H071221026/Tugas Praktikum 10/no2.py | 164 +++++++++++++++++++++++++++ 2 files changed, 276 insertions(+) create mode 100644 H071221026/Tugas Praktikum 10/no1.py create mode 100644 H071221026/Tugas Praktikum 10/no2.py diff --git a/H071221026/Tugas Praktikum 10/no1.py b/H071221026/Tugas Praktikum 10/no1.py new file mode 100644 index 0000000..b4bb508 --- /dev/null +++ b/H071221026/Tugas Praktikum 10/no1.py @@ -0,0 +1,112 @@ +import re + +name = [] +email = [] +password = [] + +while True: + print(50*'=') + print('Selamat Datang Silahkan Pilih Opsi Menu Anda') + print("1. Detail Anda") + print("2. Ubah Nama") + print("3. Jumlah data pada file") + print("4. Save data pada file") + print("5. Buat data Baru") + print("6. Keluar") + opsi = int(input("silahkan pilih opsi anda : ")) + + if opsi == 1: + if len(name) == 0 or len(email) == 0 or len(password) == 0: + print(50*'=') + print("Data saat ini kosong") + else: + print(50*'=') + print("Data anda adalah") + for nama in name: + print(f"Nama : {nama}") + for mail in email: + print(f"Email : {mail}") + for pas in name: + print(f"Password : {pas}") + elif opsi == 2: + if len(name) == 0 or len(email) == 0 or len(password) == 0: + print(50*'=') + print("Data saat ini kosong") + else: + print(50*'=') + newName = input("Silahkan input nama baru : ") + name[0] = newName + elif opsi == 3: + print(50*'=') + fileName = input("Silahkan masukkan nama file : ") + try: + with open(f"{fileName}.txt") as file: + data = file.read() + total = data.count("@student.unhas.ac.id") + print(f"Jumlah data anda adalah : {total} data") + except: + print(f"tidak terdapat file dengan nama {fileName}.txt") + print(f"Jumlah data anda adalah : 0 data") + elif opsi == 4: + if len(name) == 0 or len(email) == 0 or len(password) == 0: + print(50*'=') + print("Data saat ini kosong") + else: + print(50*'=') + namafile = input("Masukkan Nama file baru anda : ") + try: + for k in range(len(name)): + with open(f"{namafile}.txt") as baca: + baca.read() + with open(f"{namafile}.txt", "a") as table: + table.write(f"|Nama : {name[k]}\n") + table.write(f"|Email : {email[k]}\n") + table.write(f"|Password : {password[k]}\n") + table.write(f"+{'='*70}\n") + except: + for k in range(len(name)): + with open(f"{namafile}.txt", "a") as table: + table.write(f"+{'='*70}\n") + table.write(f"|Data yang tersimpan\n") + table.write(f"+{'='*70}\n") + table.write(f"|Nama : {name[k]}\n") + table.write(f"|Email : {email[k]}\n") + table.write(f"|Password : {password[k]}\n") + table.write(f"+{'='*70}\n") + name.clear() + email.clear() + password.clear() + print("Berhasil") + elif opsi == 5: + print(50*'=') + namaku = input("Silahkan masukkan nama anda : ") + name.append(namaku) + while True: + emailku = input("Silahkan masukkan email anda : ") + if re.match("^[a-z0-9]+\@student\.unhas\.ac\.id$", emailku): + email.append(emailku) + break + else: + print(50*'=') + print("Email yang anda masukkan salah") + print(50*'=') + + while True: + passwordku = input('Silahkan masukkan password anda : ') + if re.match("[\dA-Za-z]{8,20}", passwordku): + if re.match("[\dA-Za-z]", passwordku): + password.append(passwordku) + break + else: + print(50*'=') + print( + "Password yang anda masukkan terlalu lemah, gunakan minimal 1 huruf kapital, huruf kecil, dan angka") + print(50*'=') + else: + print(50*'=') + print("Password harus memiliki 8-20 karakter") + print(50*'=') + + elif opsi == 6: + print('Sampai jumpa lagi') + break diff --git a/H071221026/Tugas Praktikum 10/no2.py b/H071221026/Tugas Praktikum 10/no2.py new file mode 100644 index 0000000..ca0c15f --- /dev/null +++ b/H071221026/Tugas Praktikum 10/no2.py @@ -0,0 +1,164 @@ +class Kendaraan: + def __init__(self, merek, roda): + self.brand = merek + self.wheel = roda + + def setBrand(self, merek): + self.brand = merek + + def getBrand(self): + return self.brand + + def setWheel(self, roda): + self.wheel = roda + + def getWheel(self): + return self.wheel + + def remMendadak(self): + self._speed = 0 + + +class Motor(Kendaraan): + def __init__(self, merek, roda): + super().__init__(merek, roda) + self._speed = 140 + self._weight = 80 + self._price = 16000 + self.__pasengger = 2 + + def gasspol(self): + self._speed = self._speed+60 + + def setSpeed(self, kecepatan): + self._speed = kecepatan + + def getSpeed(self): + return self._speed + + def setWeight(self, berat): + self._weight = berat + + def getWeight(self): + return self._weight + + def setPenumpang(self, penumpang): + self.__pasengger = penumpang + + def getPenumpang(self): + return self.__pasengger + + def setHarga(self, harga): + self._price = harga + + def getHarga(self): + return self._price + + +class Mobil(Kendaraan): + def __init__(self, merek, roda): + super().__init__(merek, roda) + self._speed = 500 + self._weight = 300 + self._price = 200000 + self._pasengger = 5 + + def gasspol(self): + self._speed = self._speed+120 + + def setSpeed(self, kecepatan): + self._speed = kecepatan + + def getSpeed(self): + return self._speed + + def setWeight(self, berat): + self._weight = berat + + def getWeight(self): + return self._weight + + def setPenumpang(self, penumpang): + self._pasengger = penumpang + + def getPenumpang(self): + return self._pasengger + + def setHarga(self, harga): + self._price = harga + + def getHarga(self): + return self._price + + +class Matic(Motor): + def __init__(self, merek, roda): + super().__init__(merek, roda) + self._price = 20000 + + def special(self): + print(f'{self.brand}tidak perlu ganti gigi') + + +class Manual(Motor): + def __init__(self, merek, roda): + super().__init__(merek, roda) + self._weight = 60 + + def special(self): + self._speed = self._speed+20 + print(f'{self.brand} perlu ganti gigi tapi kecepatan bertambah 20 tiap ganti gigi menjadi {self._speed}') + + +class DuaKabin(Mobil): + def __init__(self, merek, roda): + super().__init__(merek, roda) + self._price = 210000 + self._speed = 600 + + def special(self): + print(f"Bisa Sat Set Sat Set waktu macet") + + +class TigaKabin(Mobil): + def __init__(self, merek, roda): + super().__init__(merek, roda) + self._price = 300000 + + def special(self): + self._pasengger = self._pasengger+3 + + +class Jual_Kendaraan: + def kondisiendaraan(self): + pass + + +class Bekas(Jual_Kendaraan): + def __init__(self, merek) -> None: + super().__init__() + self.brand = merek + self._price = " harga murah" + + def jualBekas(self): + print(f"jual kendaraan {self.brand} dengan {self._price}") + + +class Baru(Jual_Kendaraan): + def __init__(self, merek) -> None: + super().__init__() + self.brand = merek + self._price = "harga mahal" + + def jualBaru(self): + print(f"jual kendaraan {self.brand} dengan {self._price}") + + +Toyota = TigaKabin("Toyota", roda=4) +Toyota.gasspol() +Toyota.special() +print(f"kecepatan mobil toyota adalah : {Toyota.getSpeed()}") +print(f"Toyota dapat menampung {Toyota.getPenumpang()} penumpang") +print(f"harga mobil Toyota adalah {Toyota.getHarga()}000 rupiah") +Jual_Toyota = Baru("Toyota") +print(Jual_Toyota.jualBaru())