Skip to content

Commit ddb4e2b

Browse files
authored
Merge pull request #8939 from Aleran07/retos-de-programacion
#00 - Python
2 parents d327b0c + 7fa2a69 commit ddb4e2b

File tree

1 file changed

+78
-0
lines changed
  • Roadmap/00 - SINTAXIS, VARIABLES, TIPOS DE DATOS Y HOLA MUNDO/python

1 file changed

+78
-0
lines changed
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)

0 commit comments

Comments
 (0)