# การเขียนโปรแกรมเชิงวัตถุด้วย Python (Data Science & ML) > คลาส, อ็อบเจกต์, การสืบทอด, การห่อหุ้ม, พหุสัณฐาน, เมธอดพิเศษ, decorator - 20 คำถามสัมภาษณ์ - Junior - [คำถามสัมภาษณ์: Data Science & ML](https://sharpskill.dev/th/technologies/data-science/interview-questions.md) ## 1. คลาสใน Python คืออะไร? **คำตอบ** คลาสคือพิมพ์เขียว (blueprint) สำหรับสร้างอ็อบเจกต์ที่แชร์ attributes และ methods เดียวกัน คลาสกำหนดโครงสร้างและพฤติกรรมของอ็อบเจกต์ที่จะถูกสร้างจากมัน คลาสช่วยให้สามารถจัดระเบียบโค้ดในรูปแบบที่เป็นโมดูลและใช้ซ้ำได้โดยจัดกลุ่มข้อมูลและฟังก์ชันที่เกี่ยวข้องไว้ด้วยกัน ## 2. เมธอด __init__ ในคลาส Python มีบทบาทอย่างไร? **คำตอบ** เมธอด __init__ คือ constructor ของคลาส มันถูกเรียกโดยอัตโนมัติเมื่อสร้าง instance ใหม่และอนุญาตให้กำหนดค่าเริ่มต้นของ attributes ของอ็อบเจกต์ด้วยค่าเฉพาะ นี่คือที่ที่คุณมักจะกำหนดสถานะเริ่มต้นของอ็อบเจกต์โดยการกำหนดค่าให้กับ attributes ของ instance ผ่าน self ## 3. พารามิเตอร์ self ในเมธอดของคลาสแทนอะไร? **คำตอบ** พารามิเตอร์ self แทน instance ปัจจุบันของคลาส มันช่วยให้สามารถเข้าถึง attributes และ methods ของอ็อบเจกต์จากภายในคลาส แม้ว่าชื่อ self จะเป็นข้อตกลง แต่ก็แนะนำอย่างยิ่งให้ใช้เพื่อความสามารถในการอ่านโค้ด Python จะส่ง instance เป็นอาร์กิวเมนต์แรกโดยอัตโนมัติเมื่อเรียกใช้เมธอด ## มีอีก 17 คำถาม - ความแตกต่างระหว่าง class attribute และ instance attribute คืออะไร? - จะสร้าง instance ของคลาสชื่อ Person ใน Python อย่างไร? สมัครฟรี: https://sharpskill.dev/th/login ## หัวข้อสัมภาษณ์ Data Science & ML อื่นๆ - [พื้นฐาน Python](https://sharpskill.dev/th/technologies/data-science/interview-questions/python-basics.md): 25 คำถาม, Junior - [โครงสร้างข้อมูล Python](https://sharpskill.dev/th/technologies/data-science/interview-questions/python-data-structures.md): 20 คำถาม, Junior - [พื้นฐาน Git](https://sharpskill.dev/th/technologies/data-science/interview-questions/git-fundamentals.md): 18 คำถาม, Junior - [พื้นฐาน SQL](https://sharpskill.dev/th/technologies/data-science/interview-questions/sql-basics.md): 20 คำถาม, Junior - [พื้นฐาน NumPy](https://sharpskill.dev/th/technologies/data-science/interview-questions/numpy-fundamentals.md): 22 คำถาม, Junior - [พื้นฐาน Pandas](https://sharpskill.dev/th/technologies/data-science/interview-questions/pandas-basics.md): 22 คำถาม, Junior - [Jupyter & Google Colab](https://sharpskill.dev/th/technologies/data-science/interview-questions/jupyter-colab.md): 16 คำถาม, Junior - [SQL Joins และคิวรีขั้นสูง](https://sharpskill.dev/th/technologies/data-science/interview-questions/sql-joins-advanced.md): 22 คำถาม, Mid-Level - [Pandas ขั้นสูง](https://sharpskill.dev/th/technologies/data-science/interview-questions/pandas-advanced.md): 24 คำถาม, Mid-Level - [การแสดงผลข้อมูลด้วย Matplotlib & Seaborn](https://sharpskill.dev/th/technologies/data-science/interview-questions/matplotlib-seaborn.md): 20 คำถาม, Mid-Level - [การแสดงผลแบบโต้ตอบด้วย Plotly](https://sharpskill.dev/th/technologies/data-science/interview-questions/plotly-interactive.md): 18 คำถาม, Mid-Level - [สถิติเชิงพรรณนา](https://sharpskill.dev/th/technologies/data-science/interview-questions/statistics-descriptive.md): 20 คำถาม, Mid-Level - [สถิติเชิงอนุมาน](https://sharpskill.dev/th/technologies/data-science/interview-questions/statistics-inferential.md): 24 คำถาม, Mid-Level - [Web Scraping](https://sharpskill.dev/th/technologies/data-science/interview-questions/web-scraping.md): 18 คำถาม, Mid-Level - [BigQuery & Cloud Data](https://sharpskill.dev/th/technologies/data-science/interview-questions/bigquery-cloud.md): 18 คำถาม, Mid-Level - [Feature Engineering](https://sharpskill.dev/th/technologies/data-science/interview-questions/feature-engineering.md): 22 คำถาม, Mid-Level - [ML แบบมีผู้สอน: การถดถอย](https://sharpskill.dev/th/technologies/data-science/interview-questions/ml-supervised-regression.md): 24 คำถาม, Mid-Level - [ML แบบมีผู้สอน: การจำแนกประเภท](https://sharpskill.dev/th/technologies/data-science/interview-questions/ml-supervised-classification.md): 24 คำถาม, Mid-Level - [Decision Trees และ Ensembles](https://sharpskill.dev/th/technologies/data-science/interview-questions/ml-trees-ensembles.md): 24 คำถาม, Mid-Level - [Unsupervised ML](https://sharpskill.dev/th/technologies/data-science/interview-questions/ml-unsupervised.md): 22 คำถาม, Mid-Level - [ML Pipelines และการตรวจสอบ](https://sharpskill.dev/th/technologies/data-science/interview-questions/ml-pipelines-validation.md): 22 คำถาม, Mid-Level - [Time Series และการพยากรณ์](https://sharpskill.dev/th/technologies/data-science/interview-questions/time-series-forecasting.md): 22 คำถาม, Mid-Level - [พื้นฐาน Deep Learning](https://sharpskill.dev/th/technologies/data-science/interview-questions/deep-learning-fundamentals.md): 24 คำถาม, Senior - [TensorFlow & Keras](https://sharpskill.dev/th/technologies/data-science/interview-questions/tensorflow-keras.md): 22 คำถาม, Senior - [CNN และการจำแนกภาพ](https://sharpskill.dev/th/technologies/data-science/interview-questions/cnn-image-classification.md): 24 คำถาม, Senior - [RNN และซีเควนซ์](https://sharpskill.dev/th/technologies/data-science/interview-questions/rnn-sequences.md): 22 คำถาม, Senior - [Transformers และ Attention](https://sharpskill.dev/th/technologies/data-science/interview-questions/transformers-attention.md): 24 คำถาม, Senior - [NLP และ Hugging Face](https://sharpskill.dev/th/technologies/data-science/interview-questions/nlp-huggingface.md): 24 คำถาม, Senior - [GenAI และ LangChain](https://sharpskill.dev/th/technologies/data-science/interview-questions/genai-langchain.md): 24 คำถาม, Senior - [MLOps และการ Deploy](https://sharpskill.dev/th/technologies/data-science/interview-questions/mlops-deployment.md): 24 คำถาม, Senior --- Source: SharpSkill (https://sharpskill.dev), tech interview preparation for your real stack. HTML version of this page: https://sharpskill.dev/th/technologies/data-science/interview-questions/python-oop