Programming Fundamentals: ========================= KEYWORDS ========= ==> ARE RESERVED WORDS/BUILT-IN WORDS TO DEFINE THE SPECIAL ACTION WHILE CODING/SCRIPTING, KEYWORDS ARE USED. ==> 35 KEYWORDS ==> MODULE ==> keywords ==> Syntax for the importing of the keyword module is: import keywords ==> keywords ==> name (kwlist), is pointing to all the keywords Syntax: to make display keywords.kwlist Q: Write a script to display all the keywords of python. import keyword kw = keyword.kwlist print(kw) ['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: ========= ==> ARE OPTIONAL (BECAUSE WITHOUT THE COMMENTS ALSO, THE PROGRAM CAN EXECUTE) ==> ARE SUGGESTABLE ==> ARE READABLE ==> NOT FOR THE EXECUTION ==> WE CAN ADD COMMENTS IN ANYWHERE OF THE PROGRAM. ==> COMMENTS CAN BE WRITE IN TWO WAYS: 1) SINGLE LINE COMMENTS ==> # 2) MULTILINE COMMENTS ==> """ """ # Here we are discussing comments """ Single line comments can always start with # whereas multiline comments are always in between triple comments. """ # WRITE A SCRIPT TO ADD TWO NUMBERS. a = 10 b = 20 """ here, we have defined two values with names: a and b """ c = a + b # we were added a and b and store into c # now, i am printing print(c) # the program was closed. ================================================= IDENTIFIER =========== ==> a name used to name any entity within the program. like: variables, classes, objects, methods, functions etc. Rules for Identifier: ===================== 1) Name should define with: Alphabets (Upper case/lower case) Digits (0 to 9) Underscore sign 2) No identifier should start with a digit, but the digit can be between the identifier. ex: 9abc = 10 ==> Error abc9_23 = 100 ==> correct 3) identifier is not a keyword 4) Case Sensitive name in upper case same name in lower case ==> consider as different ex: else = 12 ==> syntax error Else = 23 ELSE = 32 ==> correct 5) No other special characters (@,space.<>?) allowed in identifier. 6) No limit in length of identifier. a = 12 # 9a = 24 Syntax Error _a9 = 24 # else = 123 Else = 23 ELSE = 32 # python@program = 123 print(a) # print(9a) print(_a9) # print(else) print(Else) print(ELSE) # print(python@program) Note: ==== _name ==> Protected data __name ==> Private data representation name ==> Public data representation __init__() __add__() __sub__() ================================================== VARIABLES -========= ==> Named memory to store any value. Dynamically Typed Language ========================== Programming Languages classified into three types: 1) Statically Typed : C int a = 12.12; a = 12 2) Strongly typed: Java Syntax for the data definition: datatype identifier = value; ex: int a = 12; int a = 12.23;==> error 3) Dynamically typed Syntax: identifier = value the programming system can automatically detect its type based value assignment. ex: a = 12 (Integer) b = 1.23 (Float) type(): ======= ==> can give the type of the data Syntax: type(identifier) id(): ===== ==> get the address location (heap memory) Syntax: id(identifier) a = 12 b = 1.23 print(type(a)) print(type(b)) # type(a) print(id(a)) print(id(b))