Python Programming tutorial provides basic and advanced concepts of Python programming. This Python programming tutorial is designed for beginners and professionals. Python is a simple, general purpose, high level, and object-oriented programming language. In this we have different chapter and their concepts Python Programming : tokens, literals, identifiers, keywords, special symbols and operators; fundamental data types, expressions, type conversions, handling Input and output in Python. Selection Statements : if statement, if-else statement, if-elif-else statement, nested-if statement. Iterative Statements : while loop, for loop, break statement, continue statement, pass and else statements used with loops. Sequences : Lists and operations - creating, inserting elements, updating elements, deleting elements, searching and sorting, list comprehensions, nested lists; tuples - creating, searching and sorting, nested tuples; strings - Initializing a...
''' 1. Encapsulation is the process of wrapping up variables and methods into a single entity. In programming, a class is an example that wraps all the variables and methods defined inside it. class One(): name = 'umamahesh' def add(self): print(' ADD is ') def sub(self): print(' SUB is:') ins = One() print('\n ', ins.name) --Using encapsulation we can give protection to the class members. It can achieve Using access modifiers. Encapsulation can be achieved using Private and Protected Access Members. ''' Example---CSE department faculty cannot access the ECE department student record and so on. Here, the department acts as the class and student records act like variables and methods. =======Why Do We Need Encapsulation?=========== ===Encapsulation acts as a protective layer by ensuring that, access to wrapped data is not possible by any code define...
''' 1. Using generator we can execute a block of code based on demand by using next() function. 2. using yield keyword we can create a generator. ''' def gen_fun(n): for i in range(n): print('Before yield') yield i print('After yield') gen_obj = gen_fun(10) #print(next(gen_obj)) #print(next(gen_obj)) # print(next(gen_obj)) ## Iterate based on for loop #for i in gen_obj: # print(' For Loop ', i) def gen_fun(n): print('Before return') yield n print(' \n After return') yield n gen_obj = gen_fun(10) print(next(gen_obj)) print(next(gen_obj))
Comments
Post a Comment