Skip to content

Instantly share code, notes, and snippets.

View dazcona's full-sized avatar
🤹‍♂️
Juggling with Data

David Azcona dazcona

🤹‍♂️
Juggling with Data
View GitHub Profile
@dazcona
dazcona / selection-sort.py
Created October 30, 2018 18:36
Selection Sort
#!/usr/bin/env python
# Selection sort.
i = 0
while i < len(a):
p = i
j = i + 1
while j < len(a):
if a[j] < a[p]:
p = j
@dazcona
dazcona / area.py
Created October 31, 2018 17:53
Area
# The area of the pitch at Old Trafford
length = 105
width = 68
area = length * width
# area # 7140
@dazcona
dazcona / var-swap.py
Created October 31, 2018 17:55
Variable Swap
tmp = a
a = b
b = tmp
@dazcona
dazcona / hello.py
Created October 31, 2018 17:59
Hello World
#!/usr/bin/env python
print "Hello, World!"
@dazcona
dazcona / double.py
Created October 31, 2018 18:01
Assignment Example
#!/usr/bin/env python
# Assume an existing integer variable n
# Write an assignment statement which doubles the value of n
n = 2 * n
@dazcona
dazcona / basics.sh
Created October 31, 2018 18:09
Shell Cheat Sheet
# Current Working Directory
# An active terminal is always associated with a particular directory known as the current working directory (CWD).
# pwd: prints the CWD name to the terminal
# cd: changes the CWD
# ls: lists the files and directories contained in the CWD
cd # Change the CWD to your home directory
cd ~ # Change the CWD to your home directory (alternative)
cd ~/Desktop # Change the CWD to your desktop directory
cd .. # Change the CWD to the parent of the CWD
ls # List the contents of the CWD
@dazcona
dazcona / squared.py
Created October 31, 2018 18:16
Squared value
#!/usr/bin/env python
n = input() # Read the integer from standard input.
print n * n # Write n squared to standard output.
@dazcona
dazcona / len.py
Created October 31, 2018 18:16
Line Length
#!usr/bin/env python
s = raw_input() # It's text, so use raw_input() instead of input().
print len(s) # Write the length to standard output.
@dazcona
dazcona / teenager.py
Created October 31, 2018 18:17
Are you a teenager?
#!/usr/bin/env python
age = input() # 1. It's an integer. 2. It's an age.
print 12 < age and age < 20
@dazcona
dazcona / rectangle.py
Created October 31, 2018 18:22
Rectangle or Square?
x = input() # The length of the base of a rectangle.
y = input() # The height of the rectangle.
if x == y:
print "square"
else:
print "rectangle"