Slide 13
Slide 13 text
Syntax
1 class Hero {
2 constructor(name) {
3 this.name = name;
4 }
5
6 superPower() {
7 console.log(`I, ${this.name},
can count really fast!`);
8 let count = 0;
9 while (count < 1000) {
10 count ++;
11 }
12 return count;
13 }
14 }
15
16 let superMan = new Hero('SuperMan');
17 superMan.superPower();
18 // I, SuperMan, can count really fast!
19 // 1000
1 class Hero:
2 def __init__(self, name):
3 self.name = name
4
5 def super_power(self):
6 print(f'I, {self.name},
can count really fast!')
7 count = 0
8 while count < 1000:
9 count += 1
10
11 return count
12
13 super_man = Hero('SuperMan')
14 super_man.super_power()
15 # I, SuperMan, can count really fast!
16 # 1000