---
title: "__init__()"  
description: "__init__()"  
author: "Prakash nidhi Verma"  
published: 2018-07-04  
updated: 2020-09-17  
canonical: https://www.mindstick.com/interview/23455/__init__  
category: "python"  
tags: ["python"]  
reading_time: 1 minute  

---

# __init__()

The __init__() Function:

classes and objects in their simplest form are not really useful in real life applications. It's a built-in __init__() function.

Example :

Use the __init__() function to assign values for name and age:

```
class Person:   def __init__(self, name, age):
    self.name = name
    self.age = age
p1 = Person("Prakash", 19)
print(p1.name)
print(p1.age)
```

## Answers

### Answer by Prakash nidhi Verma

The __init__() Function:

classes and objects in their simplest form are not really useful in real life applications. It's a built-in __init__() function.

Example :

Use the __init__() function to assign values for name and age:

```
class Person:   def __init__(self, name, age):
    self.name = name
    self.age = age
p1 = Person("Prakash", 19)
print(p1.name)
print(p1.age)
```


---

Original Source: https://www.mindstick.com/interview/23455/__init__

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
