1 2 3 4 5 6 7 8 9 10 >>> #_1 print the file path of imported modules >>> import os , socket >>> print (os) < module 'os' from 'C: \\ Program Files \\ Python \\ Python37 \\ lib \\ os.py' > >>> print (socket) < module 'socket' from 'C: \\ Program Files \\ Python \\ Python3 7 \\ lib \\ socket.py' > >>> #adding

>>> print (str(os) + '

' + str(socket)) < module 'os' from 'C: \\ Program Files \\ Python \\ Python3 7 \\ lib \\ os.py' > < module 'socket' from 'C: \\ Program Files \\ Python \\ Python37 \\ lib \\ socket.py' >

1 2 3 4 5 6 7 >>> #_2 in-place swapping of two or more numbers >>> x, y, z = 10 , 20 , 30 >>> print (x,y,z) 10 20 30 >>> x, y, z = z, x, y >>> print (x, y, z) 30 10 20

1 2 3 4 5 6 7 #_3 reversing a string in python >>> a = "I love to code in Python" >>> print ( "Reverse is:-" ,a[:: - 1 ]) Reverse is : - nohtyP ni edoc ot evol I >>> b = "IMPythonProgrammerThePySnakeBlogger" >>> print ( "Reverse is:-" ,b[:: - 1 ]) Reverse is : - reggolBekanSyPehTremmargorPnohtyPMI

1 2 3 4 5 6 7 8 9 10 >>> #_4 creating a single string from all the elements in a list >>> c = [ "Python" , "Is" , "Fun" ] >>> print ( " " . join(c)) Python Is Fun >>> print ( "-" . join(c)) Python - Is - Fun >>> print ( "

" . join(c)) Python Is Fun

1 2 3 4 5 6 7 8 >>> #_5 chaining of comparison operators >>> num = 10 >>> output = 1 < num < 20 >>> print (output) True >>> output = 1 > num <= 7 >>> print (output) False

1 2 3 4 5 6 7 8 9 10 11 12 13 14 >>> #_6 find the most frequent value in a list >>> mylist = [ 1 , 2 , 3 , 4 , 2 , 2 , 3 , 1 , 4 , 4 , 4 ] >>> print (max(set(mylist),key = mylist . count)) 4 >>> #lets break it up to understand >>> mylist = [ 1 , 2 , 3 , 4 , 2 , 2 , 3 , 1 , 4 , 4 , 4 ] >>> a = set(mylist) >>> print (a) { 1 , 2 , 3 , 4 } >>> key = mylist . count >>> print (key) < built -in method count of list object at 0x03A8FE40 > >>> print (max(a,key = mylist . count)) 4

1 2 3 4 5 >>> #_7 check the memory usage of an object >>> import sys >>> x = 1 >>> print (sys . getsizeof(x)) 14

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 >>> #_8 print string 'n' number of times >>> n = 5 >>> a = "Pysnake Blog" >>> print (a * n) Pysnake BlogPysnake BlogPysnake BlogPysnake BlogPysnake Blog >>> print (a * n + '

' ) Pysnake BlogPysnake BlogPysnake BlogPysnake BlogPysnake Blog >>> print (a + '

' * n) Pysnake Blog >>> print ((a + '

' ) * n) Pysnake Blog Pysnake Blog Pysnake Blog Pysnake Blog Pysnake Blog

1 2 3 4 5 6 7 >>> #_9 return multiple values from functions >>> def x (): return 1 , 2 , 3 , 4 >>> a,b,c,d = x() >>> print (a,b,c,d) 1 2 3 4

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 >>> #_10 use of enums in python >>> class myName : hello, world, of, python = range( 4 ) >>> print (myName . hello) 0 >>> print (myName . world) 1 >>> print (myName . of) 2 >>> print (myName . python) 3 >>> print (myName . hello,myName . world,myName . of,myName . python) 0 1 2 3

1 2 3 4 5 6 7 8 9 >>> #_11 checking if two words are anagrams >>> from collections import Counter >>> def is_anagram (str1, str2): return Counter(str1) == Counter(str2) >>> print (is_anagram( "python" , "nohtyp" )) True >>> print (is_anagram( "python" , "jython" )) False

Some python tips and tricks that I know might also help you with your coding skills. Its not that complicated all you need is practice.1) Print The File Path Of Imported Modules2) In-Place Swapping Of Two or more Numbers3) Reversing string / strings in Python4) Create a single string from all the elements in list5) Chaining Of Comparison Operators6) Find The Most Frequent Value In A List7) Check The Memory Usage Of An Object8) Print string 'n' number of times9) Return Multiple Values From Functions10) Use Of Enums In Python11) Checking if two words are anagramsHope you like the tutorial.