Skip to content

Instantly share code, notes, and snippets.

View adrianmarkperea's full-sized avatar

Adrian Mark Clave Perea adrianmarkperea

View GitHub Profile
# hi python ph :)
if __name__ == '__main__':
n = int(input())
for i in range(n):
print(i * i)
@adrianmarkperea
adrianmarkperea / corr.py
Created August 27, 2020 00:06
Simple Correlation Matrix with Heat Map using Pandas and Seaborn
import seaborn as sns
fig = plt.subplots(figsize = (10,10))
sns.set(font_scale=1.5)
sns.heatmap(df.corr(),square = True,cbar=True,annot=True,annot_kws={'size': 10})
plt.show()
class Person {
constructor(firstName, lastName) {
this.firstName = firstName;
this.lastName = lastName;
}
fullName() {
console.log(`${firstName} ${lastName}`);
}
}
Person.prototype.sayHi = function() {
console.log(`Hi! I'm ${this.firstName}`);
}
// Note that we did not recreate the objects here
personA.sayHi(); // Hi! I'm Adrian
personB.sayHi(); // Hi! I'm Be
personA.fullName === personB.fullName === Person.prototype.fullName
personA.__proto__ === Person.prototype;
function Person(firstName, lastName) {
// 1. An implicit object is created that we can reference with `this`
this.firstName = firstName;
this.lastName = lastName;
}
// 2. The resulting instance has a copy of the
// constructor function's prototype property
// inside its own prototype.
Person.prototype.fullName = function() {
function Person(firstName, lastName) {
// 1. An implicit object is created that we can reference with `this`
this.firstName = firstName;
this.lastName = lastName;
}
// 2. The resulting instance has a copy of the
// constructor function's prototype property
// inside its own prototype.
Person.prototype.fullName = function() {
function Person(firstName, lastName) {
return {
firstName,
lastName,
fullName() {
console.log(`${this.firstName} ${this.lastName}`)
}
};
}
class Person:
def __init__(self, first_name, last_name):
self.first_name = first_name
self.last_name = last_name
def print_full_name(self):
print(f'{self.first_name} {self.last_name}')
person_a = Person('Adrian', 'Perea')
person_b = Person('Ben', 'Halpern')