Skip to content

Instantly share code, notes, and snippets.

View gatukgl's full-sized avatar
🐤

Sudarat (Gatuk) Chattanon gatukgl

🐤
View GitHub Profile
@gatukgl
gatukgl / PyConUS2021TicketChallenge.py
Last active May 12, 2021 03:09
PyCon US 2021 Free Ticket Challenge
# Instructions
# 1. Write down Python code in say() method
# - This method might have one parameter `number` which possibly 1-99
# - This method need to return an English word for provided number e.g. If the number is 3, should return "three"
# 2. More examples on test data (numbers and words) are in the "Test Data Example" section
# 3. How to run this file through unit tests
# - Open the terminal
# - Run this command "python <path/to/file.py>" e.g. python PyConUS2021Challenge.py
# - If the tests are failed, it will display "FAILED (failures=16)" for example, on the terminal
# - If the tests are pass, it will display "Ran 16 tests in 0.001s OK"
# Executions
interact("walking up")
interact("walking down")
interact("walking left")
interact("walking right")
interact("pickup pencil")
interact("pickup wand")
interact("quit")
@gatukgl
gatukgl / GameInteractionWithPatternMatching.py
Created May 9, 2021 13:54
This code intend to be an example of Python code that has Pattern Matching.
def interact(action):
match action.split():
case ["walking", direction]:
goTo(direction)
case ["pickup", item]:
save(item)
case ["quit"]:
quitGame()
case _:
print("😵 Don't know this command")
@gatukgl
gatukgl / GameInteractionActions.py
Created May 9, 2021 13:25
This code intend to be an example of Python code before having Pattern Matching.
def quitGame():
print("🔴 Quit the game and go back to main page.")
def goTo(direction):
print(f"👣 Walking {direction}...")
def save(item):
print(f"💾 You got {item} 1 ea")
@gatukgl
gatukgl / MainGameInteraction.py
Last active May 9, 2021 13:23
This code intend to be an example of Python code before having Pattern Matching.
def interact(action):
command = action.split()[0]
if command == "walking":
direction = action.split()[1]
goTo(direction)
elif command == "pickup":
item = action.split()[1]
save(item)
// const and let
const name = 'gatuk'
console.log('const name >', name)
let mutableName = ''
mutableName = 'gatuk'
console.log('let mutable name > ', mutableName)
if (mutableName === 'gatuk') {
const name = 'someone'
{
"trailingComma": "es5",
"tabWidth": 2,
"semi": false,
"singleQuote": true,
"arrowParens": "avoid"
}
@gatukgl
gatukgl / heart.py
Created February 14, 2021 07:21
Drawing heart with turtle in Python
import turtle
turtle.pensize(3)
def draw_heart_curve():
for i in range(200):
turtle.right(1)
turtle.forward(1)
turtle.color("pink", "pink")
{
"editor.formatOnSave": false,
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true
},
"[json]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"prettier.singleQuote": true,
@gatukgl
gatukgl / roman_number.py
Last active August 29, 2015 14:05
Roman Number
######### Kata: Roman Number 1-30 #########
import unittest
class RomanNumberTest(unittest.TestCase):
def setUp(self):
self.roman_number = RomanNumber()
def test_number_1_should_return_I(self):