Skip to content

Commit 974d0de

Browse files
committed
2 parents 57d640d + 82f9534 commit 974d0de

File tree

19 files changed

+3337
-1478
lines changed

19 files changed

+3337
-1478
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
public class JuanGuzmanG {
2+
3+
public static void main(String args[]) {
4+
//https://docs.oracle.com/en/java/index.html
5+
6+
//tipos de comentarios
7+
//una sola linea
8+
/*
9+
comentario de
10+
varias lineas
11+
*/
12+
/**
13+
comentario de Javadoc
14+
*/
15+
16+
//variable y constante
17+
int valor = 0;
18+
final int constante = 100;
19+
20+
//primitivos
21+
boolean resultado = true;
22+
char letra = 'C';
23+
byte b = 100;
24+
short s = 10000;
25+
int i = 1000000000;
26+
27+
System.out.println("¡Hola, Java");
28+
}
29+
}
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# 00
2+
#https://www.python.org/
3+
4+
"""
5+
Esto es un comentario
6+
"""
7+
8+
'''
9+
Esto es otro comentario
10+
'''
11+
12+
mi_variable = "Una variable"
13+
14+
MY_CONSTANT = "Un constante" # Se una como indicador de constante el mayuscula
15+
16+
x = str(3) # x will be '3'
17+
y = int(3) # y will be 3
18+
z = float(3) # z will be 3.0
19+
20+
x = 5
21+
y = "John"
22+
print(type(x))
23+
print(type(y))
24+
25+
x = "John"
26+
# is the same as
27+
x = 'John'
28+
29+
30+
a = 4
31+
A = "Sally"
32+
#A will not overwrite a
33+
34+
x, y, z = "Orange", 2, "Cherry" # se pueden guardar multiples valores en una sola line
35+
print(x)
36+
print(y)
37+
print(z)
38+
39+
x = y = z = "Orange" # tambien varias variables con el mismo
40+
print(x)
41+
print(y)
42+
print(z)
43+
44+
fruits = ["apple", "banana", "cherry"]
45+
x, y, z = fruits
46+
print(x)
47+
print(y)
48+
print(z)
49+
50+
x = "Python"
51+
y = "2"
52+
z = "awesome"
53+
print(x, y, z) # se puede imprimir texto concatenando en el print
54+
55+
56+
x = "Python "
57+
y = "is "
58+
z = "awesome"
59+
print(x + y + z) # concatenar pero con el + no le agrega espacios por defecto
60+
61+
x = 5
62+
y = 10
63+
print(x + y)
64+
65+
x = 5
66+
y = "John"
67+
#print(x + y) # Esto es un error porque no se puede sumar diferente variables
68+
print(x, y)
69+
70+
x = "awesome"
71+
72+
def myfunc():
73+
global x #Existen variables globales
74+
x = "fantastic"
75+
76+
myfunc()
77+
78+
print("Python is " + x)
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Este es el sitio web oficial de Python : https://www.python.org/
2+
# Existen dos maneras para hacer comentarios en python:
3+
# Comentario de una linea
4+
# Y estas son comentarios con varias lineas:
5+
""" Hola soy Alvaro y estoy haciendo un comentario con
6+
mas de una linea, puedo seguir escribiendo pero no quiero, pero debido a este ejercicio
7+
tengo que seguir para demostrarles que aunque esto tambien sirve para declarar strings de varias lineas puede usarse como comentarios
8+
de varias lineas, tip final: esto se llama docstring"""
9+
10+
# Creando una variable normal
11+
mi_variable = "Hola soy una variable"
12+
numero = 50
13+
numero_por_dos = 50 * 2
14+
# Creando una variable constante (Python no soporta el hecho de crear variables CONSTANTE pero se sigue una convencion para indicar que es una variable constante y no debe
15+
# modificarse convencionalmente utilizando las letras mayusculas y guiones bajos, esta convencion se llama SNAKE_CASE)
16+
VARIABLE_CONSTANTE = 20 # Esta variable debe seguir la convencion de no poder cambiarse
17+
18+
# Creando variables representado todos los datos primitivos:
19+
20+
# Numero entero (int)
21+
numero_entero = 10
22+
23+
# Numero flotante (float)
24+
numero_flotante = 20.8
25+
26+
# Numero booleano (bool)
27+
variable_booleana = True
28+
29+
# Cadena de texto (str)
30+
cadena_de_texto = "Hola, mundo"
31+
32+
# Imprime por la terminal el texto: "¡Hola, [y el nombre de tu lenguaje]!"
33+
print("Hola, Python!")
34+
35+
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# 1. Crear un comentario y colocar la URL del sitio web oficial del lenguaje de programación que he seleccionado
2+
3+
# https://www.python.org/
4+
5+
# 2. Representar las diferentes sintaxis que existen para creación de comentarios
6+
7+
# (#) <- Hash caracter o numeral
8+
9+
# Este es un comentario
10+
11+
# """ <- Triple quoted string
12+
13+
"""
14+
Este es un comentario
15+
"""
16+
17+
# 3. Creación de una variable y constante
18+
nombre_de_usuario = "hardynsnet" # Variable
19+
20+
# Nota: No existe una sintaxis que indique como se crea una constante en Python
21+
# Sin embargo, se usa una convención de nomenclatura en mayusculas para representar una constante en el lenguaje
22+
PI = 3.1416 # Ejemplo
23+
24+
# 4. Creacióon de variables representando tipos de datos primitivos.
25+
anio_actual = 2025 # Entero
26+
precio = 14.45 # Flotante
27+
es_activo = True # Booleano
28+
mensaje = "Hola Mundo" # Cadena
29+
30+
# 5. Imprimir por terminal el texto: "¡Hola, [y el nombre de tu lenguaje]!"
31+
print("¡Hola, Python!")
32+
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
'''EJERCICIO:
2+
- Crea un comentario en el código y coloca la URL del sitio web oficial del
3+
lenguaje de programación que has seleccionado.
4+
- Representa las diferentes sintaxis que existen de crear comentarios
5+
en el lenguaje (en una línea, varias...).
6+
- Crea una variable (y una constante si el lenguaje lo soporta).
7+
- Crea variables representando todos los tipos de datos primitivos
8+
del lenguaje (cadenas de texto, enteros, booleanos...).
9+
- Imprime por terminal el texto: "¡Hola, [y el nombre de tu lenguaje]!"'''
10+
11+
12+
# www.python.org
13+
14+
# Esto es un comentario de una sola linea, se realiza con
15+
16+
#Esto es un comentraio multilinea
17+
#Puede escribirse en diferentes lineas
18+
19+
'''Esto es un comentario multilinea
20+
Puede escribirse en diferentes lineas'''
21+
"""
22+
Esto es un comentario multilinea
23+
Puede escribirse en diferentes lineas"""
24+
25+
# Tipos de datos primitivos
26+
CONSTANTE = "esta es sólo la manera de escribir su nombre por convencion, Python"
27+
cadena = "esto es una string"
28+
entero = 5
29+
flotante = 4.2
30+
booleano = False
31+
32+
print("¡Hola, Python!")
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Crea un comentario en el código y coloca la URL del sitio web oficial del lenguaje
2+
# Esto es un comentario. https://www.python.org/
3+
4+
5+
# Sintaxis de comentarios. Comentario uno
6+
"""
7+
Comentario dos
8+
"""
9+
'''
10+
Comentario tres
11+
'''
12+
variable = "esto es una variable" #Variable
13+
CONSTANTE = 5 # Esto es una constante por convencion
14+
15+
# tipos de variables en python
16+
17+
string = "esto es un string"
18+
boolean = True
19+
integer = 21
20+
float = 5.555
21+
22+
Print("¡Hola, Python!")
23+
24+
# that's it.
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
import java.util.List;
2+
import java.util.stream.Collectors;
3+
import java.util.stream.IntStream;
4+
5+
public class JuanGuzmanG {
6+
7+
public static void main(String args[]) {
8+
//arithmetic
9+
int additive = 1 + 1;
10+
int subtraction = 1 - 1;
11+
int multiplication = 1 * 1;
12+
float division = 1 / 2;
13+
float remainder = 1 / 2;
14+
15+
/*
16+
Unary
17+
+ indica valores positivos
18+
- indica negativos
19+
++ incremente de 1 en 1
20+
-- decrementa de 1 en 1
21+
22+
*/
23+
24+
//Operadores logicos
25+
/*
26+
|| or
27+
&& and
28+
^ xor
29+
*/
30+
31+
//operadores de comparación
32+
/*
33+
== igual a
34+
!= distinto
35+
> mayor que
36+
< menos que
37+
=> igual o mayor que
38+
<= igual o menor que
39+
*/
40+
41+
/*
42+
= asignacion
43+
+= suma el valor asignado a la variable
44+
-= resta el valor asignado a la variable
45+
int b = 9;
46+
b<<=3;
47+
System.out.print(b);
48+
*/
49+
//condicionales
50+
int condicion = 1;
51+
if(condicion==1){
52+
System.out.print(1);
53+
} else if(condicion==2){
54+
System.out.print(2);
55+
} else{
56+
System.out.print("mas de 2");
57+
}
58+
switch (condicion){
59+
case 1 -> System.out.print(1);
60+
case 2 -> System.out.print(2);
61+
}
62+
switch (condicion){
63+
case 1 -> {
64+
System.out.println(1);
65+
System.out.println("fin");
66+
}
67+
}
68+
//iterativas
69+
System.out.println("while:");
70+
int count = 2;
71+
while(count<3){
72+
count+=1;
73+
System.out.println("while: "+ count);
74+
}
75+
System.out.println("===============");
76+
int countdo = 6;
77+
do{
78+
System.out.println("dowhile: "+ countdo);
79+
countdo++;
80+
}while(countdo<6);
81+
82+
//for
83+
System.out.println("for:");
84+
int i;
85+
for(i=0; i<2;i++){
86+
System.out.println(i);
87+
}
88+
System.out.println("foreach:");
89+
int[] numbers = {1,2,3,4,5};
90+
for(int num : numbers){
91+
System.out.println(num);
92+
if(num == 3){
93+
break;
94+
}
95+
}
96+
97+
System.out.println("try catch:");
98+
double trydivision;
99+
try{
100+
trydivision = 20/0;
101+
System.out.println(trydivision);
102+
} catch(ArithmeticException e){
103+
System.out.println("no se puede dividir por 0");
104+
} finally{
105+
System.out.println("fin de division");
106+
}
107+
108+
System.out.println("dificultad extra");
109+
List<Integer> lista = IntStream.rangeClosed(10, 55)
110+
.boxed()
111+
.collect(Collectors.toList());
112+
for(Integer num : lista){
113+
if (num % 2 == 0 && num != 16 && num % 3 != 0) {
114+
System.out.println(num);
115+
}
116+
}
117+
System.out.println("con streams");
118+
IntStream.rangeClosed(10,55)
119+
.filter(n -> n % 2 == 0)
120+
.filter(n -> n % 3 != 0)
121+
.filter(n -> n != 16)
122+
.forEach(System.out::println);
123+
124+
}
125+
}

0 commit comments

Comments
 (0)