\n\n 2<\/p>\n<\/td>\n | Integer literal<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n The process of converting a sequence of characters into a sequence of tokens is called “lexical analysis”. A program or function that performs lexical analysis is called a lexical analyzer, lexer, or tokenizer. A lexer is generally combined with a parser (beyond the scope of this book), which together analyze the syntax of computer language. Python supports the following categories of tokens: NEWLINE, INDENT, DEDENT, identifiers, keywords, literals, operators, and delimiters.<\/p>\n Keywords<\/strong><\/p>\nThe following identifiers (as shown as output in the following code) are used as reserved words (or “keywords”) of the language, and cannot be used as ordinary identifiers.<\/p>\n >>> import keyword \n>>> for kwd in keyword.kwlist: \n. . .\u00a0 \u00a0 print kwd \n. . . \nand \nas \nassert \nbreak \nclass \ncontinue \ndef \ndel \nelif \nelse \nexcept \nexec \nfinally \nfor \nfrom \nglobal \nif \nimport \nin \nis \nlambda \nnot \nor \npass \nprint \nraise \nreturn \ntry \nwhile \nwith \nyield<\/p>\n One can also check if an identifier is a keyword or not using its keyword ( ) function.<\/p>\n >>> import keyword\r\n>>> keyword . iskeyword ( ' hi ' )\r\nFalse\r\n>>> keyword . iskeyword ( ' print ' )\r\nTrue<\/pre>\nDelimiters<\/strong><\/p>\nThe delimiter is a character that separates and organizes items of data. An example of a delimiter is the comma character, which acts as a field delimiter in a sequence of comma-separated values. Table 2-11 provides a list of tokens that serves as delimiters in Python.<\/p>\n \n\n\n\n Delimiters<\/p>\n<\/td>\n<\/tr>\n | \n(<\/td>\n | )<\/td>\n | [<\/td>\n | ]<\/td>\n | @<\/td>\n | {<\/td>\n | }<\/td>\n | ,<\/td>\n | :<\/td>\n | .<\/td>\n | ‘<\/td>\n | ;<\/td>\n | =<\/td>\n<\/tr>\n | \n+=<\/td>\n | -=<\/td>\n | *=<\/td>\n | \/=<\/td>\n | \/\/=<\/td>\n | %=<\/td>\n | &=<\/td>\n | l=<\/td>\n | \u2227=<\/td>\n | >>=<\/td>\n | <<=<\/td>\n | **=<\/td>\n | <\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n The following example shows how the use of delimiters can affect the result.<\/p>\n <\/p>\n >>> 5+6\/2\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0# no delimiter used\r\n8 . 0\r\n>>> (5+6)\/2\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 # delimiter used\r\n5 . 5<\/pre>\nFollowing are few points that a Python programmer should be aware of:<\/p>\n \n- The period (.) can also occur in floating-point and imaginary literals.<\/li>\n
- The simple and augmented assignment operators, serve lexically as delimiters but also perform operations.<\/li>\n
- ASCII characters “, #, and \\ have special meaning as part of other tokens or are otherwise significant to the lexical analyzer.<\/li>\n
- Whitespace is not a token but serves to delimit tokens.<\/li>\n<\/ul>\n
Integer function<\/strong><\/p>\nThe following function operates on integers (plain and long).<\/p>\n int.bit_length ( ) \nReturn the number of bits necessary to represent an integer (plain or long) in binary, excluding the sign and leading zeros.<\/p>\n >>> n=-37\r\n>>> bin(n)\u00a0 \u00a0 \u00a0 \u00a0# bin ( ) convert' integer number to a binary string\r\n' -0b100101 ' \r\n>>> n.bit_length ( )\r\n6 \r\n>>> n=2**31 \r\n>>> n\r\n2147483648L \r\n>>> bin(n)\r\n'0b10000000000000000000000000000000'\r\n>>> n.bit_length ( )\r\n32<\/pre>\nFloat functions<\/strong><\/p>\nSome of the functions for floating-point numbers are discussed below.<\/p>\n float.as_integer_ratio ( ) \nReturn a pair of integers whose ratio is exactly equal to the original float and with a positive denominator.<\/p>\n >>> ( -0 .25 ) . as_integer_ratio ( )\r\n(-1 , 4)<\/pre>\nfloat.is_integer ( ) \nReturn True if the float instance is finite with integral value, otherwise it return False.<\/p>\n >>> (-2 . 0) . is_integer ( )\r\nTrue\r\n>>> (3 . 2) . is_integer ( )\r\nFalse<\/pre>\n","protected":false},"excerpt":{"rendered":"In this Page, We are Providing Python Programming \u2013 Basics of Python. Students can visit for more Detail and Explanation of Python Handwritten Notes\u00a0Pdf. Python Programming \u2013 Basics of Python Token A token is a string of one or more characters that is significant as a group. Consider an expression: sum=6+2 The tokens in the …<\/p>\n Python Programming \u2013 Basics of Python<\/span> Read More »<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true},"categories":[5],"tags":[],"yoast_head":"\nPython Programming \u2013 Basics of Python - Python Programs<\/title>\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\t\n\t\n\t\n | |