Coggle requires JavaScript to display documents.
x = 5j print(type(y)) result: <class 'complex'>
a = "hello" print(a[1]) Imprime h
b = "world" print(b[2:5]) imprime desde el caracter 2 al 5 (rld)
#esto es un comentario
""" esto es la documentación """
y = int(2.8) # y will be 2
thislist = ["apple", "banana", "cherry"] thislist = list(("apple", "banana", "cherry")) #usar doble paréntesis
thislist[1] = "blackcurrant" thislist.append("damson")
thislist.remove("banana")
len(thislist)
thistuple = ("apple", "banana", "cherry") tuple(("apple", "banana", "cherry")) #usar doble paréntesis
thisset = {"apple", "banana", "cherry"} #usar llaves set(("apple", "banana", "cherry")) #usar doble paréntesis
thisset.add("damson")
thisset.remove("banana")
len(thisset)
thisdict = { "apple": "green", "apple": "green", "cherry": "red" } thisdict = dict(apple="green", banana="yellow", cherry="red")
thisdict["apple"] = "red"
thisdict["damson"] = "purple"
del(thisdict["banana"])
len(thisdict)
if b > a: print("b is greater than a")
fruits = ["apple", "banana", "cherry"] for x in fruits: print(x)
for x in range(2,6): print(x)
for x in range(2, 30, 3):
ej: def my_function():
my_function
def my_function(country = "Norway"):
myfunc = lambda i: i*2 print(myfunc(2))
cars = ["Ford", "Volvo", "BMW"]
cars[0]
cars[0] = "Toyota"
len(cars)
cars.append("Honda")
cars.pop(1)
cars.remove("Volvo")
class MyClass: x = 5
p1 = MyClass()
class Person: def __init__(self, name, age): self.name = name self.age = age p1 = Person("John", 36)
del p1.age del p1
def greeting(name): print("Hello, " + name)
import mymodule mymodule.greeting("Jonathan")
import mymodule as mx
dir(platform)
from mymodule import person1
person1.age, not mymodule.person1.age
import datetime x = datetime.datetime.now() print(x)
x = datetime.datetime(2020, 5, 17)
print(x.strftime("%B"))
pip --version
pip install camelcase
import camelcase