PYTHON PROGRAMMING FUNDAMENTALS ================================ KEYWORDS ========= ==> Reserved words (pre-defined words) specific meaning ==> specific action ==> 35-keywords ex: selection: if, else, elif program for even or odd even - block: odd - block: # WAP IN PYTHON TO DISPLAY ALL THE KEYWORDS OF PYTHON. """ Python library ==> Package ==> Modules ==> data ==> "keyword" ==> kwlist """ import keyword list_keywords = keyword.kwlist print(list_keywords) ['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'] ========================================== IDENTIFIERS =========== ==> a name which we can use to name any entity in the program variables, functions classes objects methods, files etc. Identifier Rules: ================ 1) Should always define with: alphabets (lower-case/upper-case/both), digits (0 to 9) and special character: _ 2) if the identifier with any special characters ==> syntax error. 3) an identifier can start with digit means ==> Syntax error. 4) When the identifier with spaces ==> Syntax Error 5) If the keyword as an identifier ==> Syntax Error 6) Keywords in Python are case Sensitive. 7) No limit in identifier length. _abc = 40 ==> correct # a@ = 100 # 9a = 100 # abc def = 9876 # if = 100 If = 90 ababababbabababbababbababbababbabababbabababbabababbabababababbababab = 123 ================================================ VARIABLES ========== a named memory acts as the container to store a value/data. Dynamically Typed programming language: ======================================= High level programming languages statically typed : C strongly typed : Java Syntax: datatype identifier = value; ex: int a = 10.23; ==> wrong in java int a = 123; int a = 10.23; ==> Correct in c 10 ==> a dynamically typed ==> Python the type of the data need not to specify at the time of definition the PVM can detect the type of value automatically during the run time of the program. a = 10 # can store at address-1 b = 20 # address-2 c = 20 d = 10 print(id(10)) # address-3 print(id(20)) # address-4 print(id(a)) print(id(b)) print(id(c)) print(id(d)) # address of the data: # id() ==> can use to get the address of the data. # syntax: id(data) # id() can give the address for only one element at a time. # type() ==> can use to find the type of the data. # Syntax: type(data) print(type(a)) DATATYPES AND LITERALS TYPE CASTING OPERATORS