Quick actions

cmd+k|ctrl+k

Navigation

Languages

comprehensive instructions

Snippet info

Language

Python

Visibility

public

Author

kamsck

Created

2024-04-11T02:36:31.143761Z

Updated

2024-04-11T02:55:29.246728Z

x=squares=[x**2 for x in range(10)]
print(x)

y=squares=[(x/2) if x>0 else 0 for x in range(10)]  # list
print(y)
z=squares={(x/2) if x>0 else 0 for x in range(10)}  # set without duplicate element
print(z)
a=squares={(x/2) if x>0 else 0 for x in [1,2,3,1,2,3]}  # set without duplicate element
print(a)

dic = {"name":"john", "age":30}
b={print("ok"  for x in dic.keys())}  #print function returns NONE and store under b
print(b)

john=20
s=[x for x in ({"name":john, "age":30}).values()]
print(s)
s=[x for x in ({"name":john, "age":30}).keys()]
print(s)

def xx(a):          #demo of lambda
    return a+10
print(xx(5))

x=lambda a: a+10
print(x(5))

john=20
s=[x for x in ({"name": john+50, "age": 30}).values()]
print(s)
x = lambda a:[a+x for x in ({"name":john+50, "age":30}).values()]
print(x(100))

x = lambda a,b :[a+x+b for x in ({"name": john+50, "age":30}).values()]
print(x(100, 50))
INFO