keywords in python ================= ==> pre-defined words which have a specific meaning ==> are also called as "reserved words". ==> total of 35 keywords in python. ==> for the keywords there is a module (pre-defined) with the name "keyword" in python library an identifier to identify all 35 keywords from "keyword" module "kwlist" ex: # to find the smallest among two numbers a = 97 b = 79 if a < b: small = a else: small = b ================================ # WRITE A PYTHON PROGRAM TO LIST AND DISPLAY ALL AVAILABLE KEYWORDS. import keyword keyword_list = keyword.kwlist # listing all the available keywords print(keyword_list) # printing of all the available keywords as a group. ['False', 'None', 'True', 'and', 'as', 'assert', 'async', 'await', 'break', 'class', 'continue', 'def', 'del', 'elif', 'else', 'except', 'finally', 'for', 'from', 'global', 'if', 'import', 'in', 'is', 'lambda', 'nonlocal', 'not', 'or', 'pass', 'raise', 'return', 'try', 'while', 'with', 'yield'] ===================================================================== COMMENTS IN PYTHON ==================== ==> most valuable part of the program ==> the comments are some extra-lines of our program which are not to be executed. ==> comments can be used for the "documentation". it can be useful for the reading purpose. ==> to add the description about the program ==> comments are used. ==> COMMENTS CAN BE ALLOWED TO ADD IN ANYWHERE OF THE PROGRAM. ==> two ways to write comments: 1) using # ==> the comments can be within the same line. (single line comments) 2) using triple quotes ==> when the comments in multiple lines # WRITE A PYTHON PROGRAM TO LIST AND DISPLAY ALL AVAILABLE KEYWORDS. import keyword # keyword_list = keyword.kwlist listing all the available keywords # # print(keyword_list) printing of all the available keywords as a group. print(keyword.kwlist) """ first approach: 1. we need to import the keyword module from python library using "import" keyword. 2. we required to prepare all the keywords as group using 'kwlist' is an identifier and 'keyword' is a module. 3. print that required or prepared group using print() """ ''' second approach: 1. we need to import the keyword module from python library using "import" keyword. 2. we should create all keywords as a group and print that group using print() ''' ============================================================ IDENTIFIERS IN PYTHON ===================== ==> WHEN WE REQUIRED TO NAME ANY ENTITY IN THE PROGRAM, WE USED "IDENTIFIERS". HERE, ENTITIES OF PROGRAM ARE: VARIABLES ==> FOR THE DATA STORAGE. FUNCTIONS ==> MODULAR APPROACH CLASS ==> OBJECT, METHODS, MODULES, PYTHON FILE ETC. RULES FOR AN IDENTIFIERS:' ========================= 1) THE ALLOWED CHARACTERS: alphabets ==> upper case/lower case/both digits ==> 0 to 9 only one special character ==> _ (underscore) ex: ravi_27, python, etc ==> valid identifiers 2) THE IDENTIFIER SHOULD NEVER START WITH DIGIT. EX: 97abc, 123ravi etc. ==> invalid Note: if the identifier with the digit at the beginning ==> Syntax Error Note: if the idnetifier with underscore at the start ==> valid 3) THE IDENTIIFER NEVER BE INCLUDE WITH SPACE. Note: if an identifier with space ==> Syntax Error. 4) THE IDENTIFER NEVER ALLOWED WITH ANY OTHER SPECIAL CHARACTERS. Note: if an identifier with a special character ==> Syntax Error. 5) IDENTIFERS ARE CASE SENSITIVE. EX: A NAME WITH LOWER CASE AND SAME NAME WITH UPPER CASE, BOTH ARE CONSIDERED BY THE INTERPRETER AS DIFFERENT. ex: abc = 100 ABC = 200 6) NO LIMIT IN LENGTH OF AN IDENTIIFER. abc = 100 # valid identifier abc_123 = 1000 # 123abc = 10000 _123 = 10000 _abc = 9797 # python program = 121212 # abc@12 = 1234565 Abc = 1212 ABC = 2121 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA = 123456789 print(_123) print(abc) print(abc_123) # print(123abc) print(_abc) # print(python program) # print(abc@12) print(Abc) print(ABC) print(AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA) ================================================== ASSIGNMENT =========== IDENTIFY THE VALID AND INVALID IDENTIFIERS AND MENTION THE REASON. rateofInterest rate@123 python c# c++ java sbiloanrate myClass class_1212 1_class ===================================================== IO OPERATIONS ============== ==> IO ==> INPUT AND OUTPUT OPERATIONS INPUT ==> READING A VALUE ==> TAKING THE VALUE FROM THE KEYWORD. ==> input() OUTPUT ==> WRITING A VALUE ==> DISPLAY ANYTHING ON THE SCREEN print()