Coggle requires JavaScript to display documents.
def my_function(*kids): print("The youngest child is " + kids[2]) my_function("Emil", "Tobias", "Linus")
def my_function(child3, child2, child1): print("The youngest child is " + child3) my_function(child1 = "Emil", child2 = "Tobias", child3 = "Linus")
def my_function(**kid): print("His last name is " + kid["lname"]) my_function(fname = "Tobias", lname = "Refsnes")
def my_function(country = "Norway"): print("I am from " + country) my_function("Sweden") my_function()
x = lambda a, b : a * b print(x(5, 6))
x={"name" : "John", "age" : 36}
x=["apple", "banana", "cherry"]
thislist = ["apple", "banana", "cherry"] print(thislist[-1])
x=("apple", "banana", "cherry")
thistuple = ("apple",) print(type(thistuple)) #NOT a tuple thistuple = ("apple") print(type(thistuple))
x=range(6)
range(2, 30, 3) step is 3
x =1j
x=b"Hello"
x=bytearray(5)
x = memoryview(bytes(5))
x={"apple", "banana", "cherry"}
x = frozenset({"apple", "banana", "cherry"})
b = "Hello, World!" print(b[2:5]) print(b[-5:-2]) print(b[-5:]) print(b[:3])
txt = "The rain" x = "ain" in txt print(x)
quantity = 3 itemno = 567 price = 49.95 myorder = "I want to pay {2} dollars for {0} pieces of item {1}." print(myorder.format(quantity, itemno, price))
a = 2 b = 330 print("A") if a > b else print("B")
for x in range(6): print(x) else: print("Finally finished!")
i = 1 while i < 6: print(i) i += 1 else: print("i is no longer less than 6")
import mymodule
from mymodule import person1 print (person1["age"])
x = 200 print(isinstance(x, int))
class Person: def __init__(self, name, age): self.name = name self.age = age def myfunc(self): print("Hello my name is " + self.name) p1 = Person("John", 36) p1.myfunc()
datetime.datetime.now()
import datetime x = datetime.datetime(2018, 6, 1) print(x.strftime("%B"))
x, y, z = "Orange", "Banana", "Cherry"
def myfunc(): global x x = "fantastic"
x = "awesome" def myfunc(): global x x = "fantastic"
json.dumps(x, indent=4)
class Student(Person)
thislist = ["apple", "banana", "cherry"] del thislist[0] del thislist