Posts

Showing posts from August, 2020

F-Strings & String Formatting In Python

me = "Santosh" my = "and being a developer" life = "is my life's" aim = "biggest dream" a = f"this is { me } { my } { life } { aim } " print (a) """ f-string is using for merge multiple variable is a single line using {} """  

Using Python External & Built In Modules

  # import random # random_number = random.randint(0, 15) # # print(random_number) # rand = random.random() * 50 # # print(rand) # lst = ["star plus", "zee tv", "colours", "& pictures", "dd national"] # choice = random.choice(lst) # print(choice) ################# MY CODE ################## # import calendar # # print("Find your month and year") # a = int(input("Enter year : \n")) # year is always on top # b = int(input("Enter month : \n")) # month is after getting year # calendar = calendar.month(a , b) # print("\n", calendar)

Anonymous/Lambda Functions In Python

  # Lambda functions or anonymous functions # def add(a, b): # return a+b # minus = lambda x, y: x-y # def minus(x, y): # return x-y # # print(minus(9, 4)) # a = [[1, 14], [5, 6], [8, 23]] # a.sort(key=lambda x: x[1]) # print(a)

While Loops In Python.

  ############## While loop Tutorial ######### i = 0 # While Condition is true # Inside code of while keep runs # This will keep printing 0 # while(i<45): # print(i) # To stop while loop # update i to break the condition while ( i < 8 ): print ( i ) i = i + 1 # Output : # 0 # 1 # 2 # 3 # 4 # 5 # 6 # 7 # 8 # Assuming code inside for and while loop is same ...

For Loops In Python.

 ines (83 sloc) 1.75 KB ################### For Loop Tutorial ############### # A List list1 = [ 'Vivek' , 'Larry' , 'Carry' , 'Marie' ] # To print all elements in list print ( list1 [ 0 ]) print ( list1 [ 1 ]) print ( list1 [ 2 ]) print ( list1 [ 3 ]) # Output : # Vivek # Larry # Carry # Marie # We can do same thing easily using for loop # for loop runs len(list1) times # each time ite...

Sets In Python

  # with no duplicate elements. # Basic uses include membership testing # and eliminating duplicate entries. # Set objects also support mathematical operations # like union, intersection, difference, # and symmetric difference. s = set () print ( type ( s )) # Output : <class 'set'> l = [ 1 , 2 , 3 , 4 ] s_from_list = set ( l ) print ( s_from_list ) # Output : {1, 2, 3, 4} print ( type ( s_from_list )) # Output : <class 'set'> s . add ( 1 ) # 1 will be added to empty set s print ( s ) # Output : {1} ...

Modules & Pip.py

  # Sometimes we have to use someone else’s code(Module) in our program # because it saves our lot of time and off-course it is legal and free. #### Modules #### # Module – Module or library is the file which contain definitions of several functions, # classes, variables, etc. which are written by someone else for free use. #### Pip #### # Pip – Pip is a package manager in python # i.e. pip command is used to download any external module in python. # It is something like which helps us to get something from somewhere # and automatically save packages at suitable location for futher use. ### We can install any...

Complete-Python-Tutorial-and-Notes

  # Python Programming language was developed by Guido Van Rossum in February 1991. # It is an interpreted, high-level, general-purpose programming language. # Programming helps human to reduce manual efforts and # work which take hours to complete can be accomplished by computer in Seconds. # To write any language’s code we need a platform where # we can write the code and can execute it. # For this we use IDE’s. # IDE – IDE (Integrated Development Environment) # is a software application which provides many comprehensive facilities # to programmers for software or application development. # You can use Pycharm and Visual Studio Code as IDE ############################################################################# ####### Inst...