Quick actions

cmd+k|ctrl+k

Navigation

Languages

Python Web - L02

Snippet info

Language

Python

Visibility

public

Author

victormakwaitat

Created

2025-02-04T01:11:30.295402Z

Updated

2025-02-04T04:47:51.632169Z

t = 1,2,3
print(type(t),t)

t = 1,  # single tuple
print(type(t),t)

t = (1)
print(type(t),t)

t = tuple() #create empty tuple using tuple function
print(type(t),t)

t = ()  #danger using () to create tuple
print(type(t),t)

l = [1,2,3]
l.append(4)
print(l)
#t.append(4) # In this case, we cannot use append function with tuple

t = tuple(l) # List changes to Tuple
print(t)

t = 1,2,3,4,5,6
l = list(t) # Tuple changes to List
print(l)

def a():
    x = 1
    y = 2
    print(x,y)
a()
a()
print(a()) # print value firstly, and then print return value = None
def a():
    x = 1
    y = 2
    return x, y
y = a()
print(type(y), y)

def a(x, y):
    return x + y
y = a(1,2)
print(type(y), y)
y = a(1,2) + a(3,4)
print(type(y), y)

def a(x, y):    # this is function a#
    print(x,y)  # @1.5 x=1, y=2
    x1 = x  # define x with value 1
    y1 = y  # define y with value 2
    print(x1, y1)
    return x1 + y1
a(1,2)
print(a)
print(a(1,2) + a(3,4)) # print(3 + a(3,4) print(3+7) print(10))
INFO