Senin, 9 Maret 2026
Sumbarkita.id
Tidak Ada
Lihat Semua Hasil
  • Home
  • Zona Sumbar
  • Peristiwa
  • Hukum & Kriminal
  • Politik
  • Pesona Sumbar
  • Zona Viral
  • Pendidikan
  • Kesehatan
  • Home
  • Zona Sumbar
  • Peristiwa
  • Hukum & Kriminal
  • Politik
  • Pesona Sumbar
  • Zona Viral
  • Pendidikan
  • Kesehatan
Sumbarkita.id
Tidak Ada
Lihat Semua Hasil
  • Home
  • Zona Sumbar
  • Peristiwa
  • Hukum & Kriminal
  • Politik
  • Pesona Sumbar
  • Zona Viral
  • Pendidikan
  • Kesehatan
Python 3- Deep Dive -Part 4 - OOP-

In the previous parts of this series, we explored the basics of Python 3, including data types, control structures, and functions. In this article, we’ll take a deep dive into one of the most powerful features of Python: Object-Oriented Programming (OOP). OOP is a programming paradigm that revolves around the concept of objects and classes, and it’s widely used in software development. What is Object-Oriented Programming? Object-Oriented Programming is a programming approach that simulates real-world objects and systems by creating objects that have properties and behaviors. In OOP, a program is designed as a collection of objects that interact with each other to achieve a specific goal.

Here’s an example of a simple class in Python:

An , on the other hand, is an instance of a class. It has its own set of attributes (data) and methods (functions) that are defined in the class.

class Person: def __init__(self, name, age): self.name = name self.age = age person = Person('John Doe', 30) print(person.name) # Output: John Doe print(person.age) # Output: 30 Inheritance is a mechanism that allows one class to inherit the properties and behaviors of another class. The class that inherits the properties is called the subclass or derived class , while the class being inherited is called the superclass or base class .

This car is a 2015 Toyota Corolla with 0 miles. This car is a 2015 Toyota Corolla with 100 miles. In Python, the __init__ method is a special method that’s called a constructor. It’s used to initialize the attributes of a class when an object is created.

class Car: def __init__(self, brand, model, year): self.brand = brand self.model = model self.year = year self.mileage = 0 def drive(self, miles): self.mileage += miles def describe_car(self): print(f"This car is a {self.year} {self.brand} {self.model} with {self.mileage} miles.") In this example, Car is a class that has four attributes: brand , model , year , and mileage . It also has two methods: drive and describe_car . To create an object from a class, you use the class name followed by parentheses that contain the required arguments. Here’s how you can create a Car object:

Here’s an example of inheritance in Python:

The __init__ method is called automatically when an object is created from a class. Here’s an example:

#TERPOPULER

  • 3 Pelajar Tertabrak Kereta Api di Padang, 2 Orang Tewas, 1 Korban Kritis

    3 Pelajar Tertabrak Kereta Api di Padang, KAI: Masinis Bunyikan Klakson Berkali-kali

    0 shares
    Share 0 Tweet 0
  • 3 Pelajar Tertabrak Kereta Api di Padang, 2 Orang Tewas, 1 Korban Kritis

    0 shares
    Share 0 Tweet 0
  • Dari Lapas, 4 Narapidana Tipu Anggota Polres Tanah Datar, Korban Rugi Rp35 Juta

    0 shares
    Share 0 Tweet 0
  • Truk Tabrak Motor dan Mobil Fortuner di Pasaman Barat, 1 Orang Tewas

    0 shares
    Share 0 Tweet 0
  • Modus Bisnis Beras Fiktif, Wanita di Tanah Datar Tipu PNS hingga Rp700 Juta

    0 shares
    Share 0 Tweet 0

Terkini

-part 4 - Oop- - Python 3- Deep Dive

In the previous parts of this series, we explored the basics of Python 3, including data types, control structures, and functions. In this article, we’ll take a deep dive into one of the most powerful features of Python: Object-Oriented Programming (OOP). OOP is a programming paradigm that revolves around the concept of objects and classes, and it’s widely used in software development. What is Object-Oriented Programming? Object-Oriented Programming is a programming approach that simulates real-world objects and systems by creating objects that have properties and behaviors. In OOP, a program is designed as a collection of objects that interact with each other to achieve a specific goal.

Here’s an example of a simple class in Python:

An , on the other hand, is an instance of a class. It has its own set of attributes (data) and methods (functions) that are defined in the class. Python 3- Deep Dive -Part 4 - OOP-

class Person: def __init__(self, name, age): self.name = name self.age = age person = Person('John Doe', 30) print(person.name) # Output: John Doe print(person.age) # Output: 30 Inheritance is a mechanism that allows one class to inherit the properties and behaviors of another class. The class that inherits the properties is called the subclass or derived class , while the class being inherited is called the superclass or base class .

This car is a 2015 Toyota Corolla with 0 miles. This car is a 2015 Toyota Corolla with 100 miles. In Python, the __init__ method is a special method that’s called a constructor. It’s used to initialize the attributes of a class when an object is created. In the previous parts of this series, we

class Car: def __init__(self, brand, model, year): self.brand = brand self.model = model self.year = year self.mileage = 0 def drive(self, miles): self.mileage += miles def describe_car(self): print(f"This car is a {self.year} {self.brand} {self.model} with {self.mileage} miles.") In this example, Car is a class that has four attributes: brand , model , year , and mileage . It also has two methods: drive and describe_car . To create an object from a class, you use the class name followed by parentheses that contain the required arguments. Here’s how you can create a Car object:

Here’s an example of inheritance in Python: What is Object-Oriented Programming

The __init__ method is called automatically when an object is created from a class. Here’s an example:

Wakil Wali Kota Padang Buka Yatim Fest 1447 H, Diikuti 400 Anak Yatim dan 200 Bunda Tangguh

Wakil Wali Kota Padang Buka Yatim Fest 1447 H, Diikuti 400 Anak Yatim dan 200 Bunda Tangguh

Senin, 09 Maret 2026 | 07:00 WIB
Hadiri Pelantikan DPD BKPRMI Padang Panjang, Wawako Allex Saputra Ajak Generasi Muda Makmurkan Masjid

Hadiri Pelantikan DPD BKPRMI Padang Panjang, Wawako Allex Saputra Ajak Generasi Muda Makmurkan Masjid

Senin, 09 Maret 2026 | 06:00 WIB
Jadwal Imsak Hari Ini 28 Februari 2026 di Padang

Jadwal Imsak di Padang Hari Ini, 9 Maret 2026

Senin, 09 Maret 2026 | 03:00 WIB
Bank Nagari Imbau Nasabah Waspada Penipuan Digital, Ini Tips Keamanan Transaksi

Bank Nagari Tegaskan Komitmen Tolak Gratifikasi Jelang Lebaran 2026

Senin, 09 Maret 2026 | 00:30 WIB
Next Post
Bupati Padang Pariaman Audiensi ke Kementerian, Usulkan BSPS dan Penanganan Kawasan Kumuh

Bupati Padang Pariaman Audiensi ke Kementerian, Usulkan BSPS dan Penanganan Kawasan Kumuh

Icon SK White 2__

Informasi

  • Redaksi & Perusahaan
  • Tentang Kami
  • Pedoman Media Siber
  • Kode Etik Jurnalistik
  • Privacy Policy

Berita

  • Zona Sumbar
  • Zona Viral
  • Hukum & Kriminal
  • Peristiwa
  • Pesona Sumbar
  • Pendidikan
  • Politik
  • Gaya Hidup
  • Ekonomi & Bisnis

Alamat

Jl. Jihad Raya No.60, Kubu Dalam Parak Karakah, Kec. Padang Timur, Kota Padang, Sumatera Barat
Phone (0751) 4773713
email:

©2026 sumbarkita.id. All right reserved

Icon SK White 2__

Follow Us

Berita

  • Zona Sumbar
  • Zona Viral
  • Hukum & Kriminal
  • Peristiwa
  • Pesona Sumbar
  • Pendidikan
  • Politik
  • Gaya Hidup
  • Ekonomi & Bisnis
  • Redaksi & Perusahaan
  • Tentang Kami
  • Pedoman Media Siber
  • Kode Etik Jurnalistik
  • Privacy Policy

©2026 sumbarkita.id. All right reserved

Tidak Ada
Lihat Semua Hasil
  • Zona Sumbar
    • Kabupaten Dharmasraya
    • Kabupaten Limapuluh Kota
    • Kabupaten Padang Pariaman
    • Kabupaten Pasaman Barat
    • Kabupaten Pesisir Selatan
    • Kabupaten Sijunjung
    • Kabupaten Solok
    • Kabupaten Solok Selatan
    • Kota Bukittinggi
    • Kota Padang
    • Kota Padang Panjang
    • Kota Pariaman
    • Kota Payakumbuh
    • Kota Solok
  • Advertorial
  • Artikel & Opini
  • Bank Nagari
  • DPRD Dharmasraya
  • DPRD Padang
  • DPRD Pasaman Barat
  • DPRD Sumatra Barat
  • Ekonomi & Bisnis
  • Gaya Hidup
  • Hiburan
  • Hukum & Kriminal
  • Info Loker
  • Internasional
  • Kesehatan
  • Nasional
  • Olahraga
  • Otomotif
  • PDAM Payakumbuh
  • Pemilu
  • Pendidikan
  • Peristiwa
  • Pesona Sumbar
  • Pilkada
  • PLN
  • Politik
  • PT Semen Padang
  • Sumbar Flashback
  • Tekno
  • Zona Riau
  • Zona Viral

© Copyright 2025Sumbarkita.id