Comments and Classes in Python
Day 11 in #100DaysOfCode
Comments
In Python, a comment begins with the hash character # and extends to the end of the physical line. However, a hash character within a string value is not considered a comment. A remark can be written in three ways: completely on its own line, adjacent to a code statement, or as a multi-line comment block.
Classes
We use classes to define new types. These new types model real concepts. We start defining a class with the "class" keyword and then we give it a name. Note that we do not use an underscore while naming classes. We must capitalize the first letter of every word. This is called Pascal Naming Convention.
We add two line breaks after defining the class. Example: let's define a class called "Person".
class Person:
def __init__(self, name, age):
self.name = name
self.age = age
p1 = Person("İlke", 10)
print(p1.name)
print(p1.age)
Result:
İlke
10
Process finished with exit code 0