Skip to content

Instantly share code, notes, and snippets.

@abhi923
Created June 28, 2020 10:51
Show Gist options
  • Save abhi923/ba641ca2f2a576149c30b8679f74d449 to your computer and use it in GitHub Desktop.
Save abhi923/ba641ca2f2a576149c30b8679f74d449 to your computer and use it in GitHub Desktop.
dct = { 'one':'two','three':'one', 'two':'three'}
v = dct['three']
for k in range (len(dct)):
v = dct[v]
print(v)
def fun(x):
x += 1
return x
x = 2
x = fun(x+1)
print (x)
tup = (1,2,4,8)
tup = tup [1:-1]
tup = tup [0]
print(tup)
def function (x=0):
return x
def fun(inp =2, out=3):
return inp *out
print(fun(out=2))
dct ={ }
lst = ['a','b','c','d']
for i in range (len(lst) - 1):
dct[lst[i]] = (lst[i], )
for i in sorted (dct.keys()):
k = dct[i]
print(k[0])
def any ():
print(var + 1, end='')
var = 1
any()
print(var)
def funcl(a):
return a**a
def func2(a):
return funcl(a) * funcl(a)
print(func2(2))
def fun (x):
global y
y = x*x
return y
fun(2)
print(y)
def fun(x):
if x % 2 ==0:
return 1
else:
return 2
print(fun(fun(2)))
x = 1
y = 2
x,y,z = x,x,y
z,y,z = x,y,z
print(x,y,z)
lst = [[x for x in range(3)] for y in range (3)]
for r in range(3):
for c in range(3):
if lst[r][c]%2 != 0:
print('#')
def fun(x, y):
if x == y:
return x
else:
return fun(x, y-1)
print(fun(0, 3))
lst = [1,2]
for v in range(2):
lst.insert(-1, lst[v])
print(lst)
tup = (1,2,4,8)
tup = tup [-2:-1]
tup = tup[-1]
print(tup)
list = [x*x for x in range(5)]
def fun (lst):
del lst [lst[2]]
return lst
print(fun(list))
print(1/2)
def func(a,b):
return b**a
print(func(b=2, a=2))
def func1(a):
return 2
def func2(a):
return func1(a)* func1(a)
print(func2(2))
z = 0
y = 10
x = y<z and z>y or y>z and z<y
print(x)
lst = [i for i in range(-1, -2)]
print(lst)
x= 1//5 + 1/5
print(x)
a = 1
b = 0
a = a^b
b = a^b
a = a^b
print(a,b)
print('a', 'b','c', sep ='sep')
dct = {}
dct['1'] = (1,2)
dct['2'] = (2,1)
for x in dct.keys():
print(dct[x][1], end='')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment