| 
									
										
										
										
											2018-10-12 15:37:13 -04:00
										 |  |  | --- | 
					
						
							|  |  |  | title: Python Ord Function | 
					
						
							|  |  |  | --- | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ## Ord function
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-18 16:54:13 -08:00
										 |  |  | `ord()` is a built-in function in Python 2.7 & 3, to convert the string representing one Unicode character into integer  | 
					
						
							| 
									
										
										
										
											2018-10-12 15:37:13 -04:00
										 |  |  | representing the Unicode code of the character. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #### Examples:
 | 
					
						
							|  |  |  | ``` | 
					
						
							|  |  |  | >>> ord('d') | 
					
						
							|  |  |  | 100 | 
					
						
							|  |  |  | >>> ord('1') | 
					
						
							|  |  |  | 49 | 
					
						
							|  |  |  | ``` | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ## chr function
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-18 16:54:13 -08:00
										 |  |  | `chr()` is a built-in function in Python 2.7 & 3, to convert the integer  | 
					
						
							| 
									
										
										
										
											2018-10-12 15:37:13 -04:00
										 |  |  | representing the Unicode code into a string representing a corresponding character. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #### Examples:
 | 
					
						
							|  |  |  | ``` | 
					
						
							|  |  |  | >>> chr(49) | 
					
						
							|  |  |  | '1' | 
					
						
							|  |  |  | ``` | 
					
						
							|  |  |  | One thing is to be noted that, if the integer value passed to `chr()` is out of range then, a ValueError will be raised. | 
					
						
							|  |  |  | ``` | 
					
						
							|  |  |  | >>> chr(-10) | 
					
						
							|  |  |  | 'Traceback (most recent call last): | 
					
						
							|  |  |  |   File "<pyshell#24>", line 1, in <module> | 
					
						
							|  |  |  |     chr(-1) | 
					
						
							|  |  |  | ValueError: chr() arg not in range(0x110000)' | 
					
						
							|  |  |  | ``` | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 |