This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Person { | |
String name; | |
int age; | |
Person(this.name, this.age); | |
void lieAboutMyAge() { | |
print("My name is $name, my age is ${age - 10}"); | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from time import sleep | |
while True: | |
try: | |
print("Try and stop me") | |
sleep(1) | |
except Exception: | |
print("Ok I'll stop!") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from time import sleep | |
while True: | |
try: | |
print("Try and stop me") | |
sleep(1) | |
except: | |
print("Don't.. stop.. me now!") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try: | |
... | |
except: | |
pass |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> class Card: | |
... __slots__ = 'rank', 'suite' | |
... def __init__(self, rank, suite): | |
... self.rank = rank | |
... self.suite = suite | |
... | |
>>> qh = Card('queen', 'hearts') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> # Calculate all profucs of an input | |
>>> list(itertools.product('abc', repeat=2)) | |
[('a', 'a'), ('a', 'b'), ('a', 'c'), | |
('b', 'a'), ('b', 'b'), ('b', 'c'), | |
('c', 'a'), ('c', 'b'), ('c', 'c')] | |
>>> # Calculate all permutations | |
>>> list(itertools.permutations('abc')) | |
[('a', 'b', 'c'), ('a', 'c', 'b'), ('b', 'a', 'c'), | |
('b', 'c', 'a'), ('c', 'a', 'b'), ('c', 'b', 'a')] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{'name': 'Ed', 'age': 24}, | |
{'name': 'Jane', 'age': 34}, | |
{'name': 'Janet','age': 34}, | |
{'name': 'John', 'age': 32}, | |
{'name': 'John', 'age': 64}, | |
{'name': 'John', 'age': 99}, | |
{'name': 'Sara', 'age': 64} | |
] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import operator | |
people.sort(key=operator.itemgetter('age')) | |
people.sort(key=operator.itemgetter('name')) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
people = [ | |
{ 'name': 'John', "age": 64 }, | |
{ 'name': 'Janet', "age": 34 }, | |
{ 'name': 'Ed', "age": 24 }, | |
{ 'name': 'Sara', "age": 64 }, | |
{ 'name': 'John', "age": 32 }, | |
{ 'name': 'Jane', "age": 34 }, | |
{ 'name': 'John', "age": 99 }, | |
] |
NewerOlder