This file contains 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
public class BreakContinue { | |
public static void main(String [] args) { | |
Integer cuenta = 100; | |
for (Integer i=0; i<cuenta; i++) { | |
if (i % 13 == 0 && i > 20) { | |
System.out.println("saliendo prematuramente..."); | |
break; | |
} | |
System.out.println("Numero: " + i.toString()); |
This file contains 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
public class BreakContinue { | |
public static void main(String [] args) { | |
Integer cuenta = 100; | |
System.out.println("Imprimiendo numeros pares"); | |
for (Integer i=0; i<cuenta; i++) { | |
if (i % 2 != 0) { | |
continue; | |
} | |
System.out.println(i.toString()); |
This file contains 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 ArrayDemo { | |
public static void main(String[] args) { | |
// declares an array of integers | |
int[] anArray; | |
// allocates memory for 10 integers | |
anArray = new int[10]; | |
// initialize first element | |
anArray[0] = 100; |
This file contains 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 ArrayDemo { | |
public static void main(String[] args) { | |
Integer[] anArray = new Integer[10]; | |
for (Integer i = 0; i < 10; i++) { | |
anArray[i] = (i + 1) * 100; | |
} | |
for (Integer i = 0; i < 10; i++) { | |
System.out.println("Element at index " + i.toString() + ": " + anArray[i].toString()); |
This file contains 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 A: | |
def __init__(self, parama): | |
self.parama = parama | |
class B(A): | |
def __init__(self, parama): | |
A.__init__(self,parama) |
This file contains 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
st = "{'a':'b','c':'d'}" | |
dc = dict([[g.replace("'","").replace('"',"") for g in f.split(":")] for f in st[1:-1].split(",")]) | |
st2 = "'a':'b','c':'d'" | |
dc = dict([[g.replace("'","").replace('"',"") for g in f.split(":")] for f in st2[1:-1].split(",")]) |
This file contains 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
def serializeFields(data): | |
try: | |
it = iter(data) | |
except TypeError as terr: | |
return unicode(data) | |
if type(it) == type(iter([])): | |
l = [] | |
for e in it: | |
l.append(serializeFields(e)) | |
return l |
This file contains 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
NUMBER, OPER, NONE = "NUMBER", "OPER", "NONE" | |
VALID_OPERS = ["+", "-", "*", "/", "^"] | |
class Token(object): | |
def __init__(self, type, value): | |
self.type = type | |
self.value = value | |
def __str__(self): | |
return "{} {}".format(self.type, self.value) |