''' 1. Using sys module we can do system related operation. ''' import sys print(sys.version) ## to append path #sys.path.append(r'C:\\Users\\sriram\\Desktop\\akr') ## To exit from execution print(' \n Before exit') sys.exit() print(' \n After exit') -------------Input and Output using sys The sys modules provide variables for better control over input or output. We can even redirect the input and output to other devices. This can be done using three variables – 1.stdin 2.stdout 3.stderr ----stdin---: It can be used to get input from the command line directly. It used is for standard input. It internally calls the input() method. It, also, automatically adds ‘\n’ after each sentence. import sys for line in sys.stdin: if 'q' == line.rstrip(): break print(f'Input : {line}') print("Exit") --------stdout-------: A built-in file object that is to the interpreter’s standard out...
## Using __init__ we can create constructor ## Using constructor we can create instance varables. ## Constructor method will call when calling class class One: def __init__(self, name, eid): self.name = name self.eid = eid print('__init__') def add(self): print(' Add ', self.name) def sub(self): print(' SUB ', self.name) print(' SUB EID ', self.eid) inst = One('UMAMAHESH', 999) #inst.add() #inst.sub()
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...
Comments
Post a Comment