Skip to content

Instantly share code, notes, and snippets.

View ntcho's full-sized avatar
🚀
Ready

Nathan Cho ntcho

🚀
Ready
View GitHub Profile
@ntcho
ntcho / LoopPython.py
Last active April 22, 2017 14:26
Python Loops
for i in range(0, 6):
print i
j = 0
while j < 5:
print j
j += 1
k = 0
while True:
@ntcho
ntcho / LoopC++.cpp
Created April 10, 2017 00:38
C++ Loops
int main() {
int i = 0, j = 0, k = 0;
// for statement
for (i = 0; i < 5; i++) {
print(i);
}
// while statement
while (j < 5) {
print(j++);
@ntcho
ntcho / LoopJava.java
Last active April 10, 2017 00:18
Java loops
public static void main(String args[]) {
int i = 0, j = 0, k = 0;
// for statement
for (i = 0; i < 5; i++) {
print(i);
}
// while statement
while (j < 5) {
print(j++);
@ntcho
ntcho / gist:00cea0e703d7c9642e72821b05009cc2
Created March 27, 2017 03:22
python programmatic flow error message
Traceback (most recent call last):
File "FILENAME", line 12, in <module>
repeat_lyrics()
NameError: name 'repeat_lyrics' is not defined
Process finished with exit code 1
@ntcho
ntcho / programmatic-flow.py
Created March 20, 2017 02:57
Python's programmatic flow
def print_lyrics():
print "I'm a lumberjack, and I'm okay"
print "I sleep all night and I work all day"
# repeat_lyrics()
# return an error: "NameError: name 'repeat_lyrics' is not defined"
def repeat_lyrics():
@ntcho
ntcho / SwapFuncOverloading.cpp
Created March 16, 2017 10:35
Function Overloading
#include <iostream>
void swap(int *n1, int *n2);
void swap(char *n1, char *n2);
void swap(double *n1, double *n2);
int main() {
int num1 = 20, num2 = 30;
swap(&num1, &num2);
std::cout << num1 << ' ' << num2 << std::endl;