# Return value of chr(ord('A')) in Python

**Python example of chr() and ord() functions**: Here, we are going to learn about the functions **chr() and ord() functions in python**.

Submitted by **IncludeHelp**, on March 31, 2019

## 1) Python ord() function

**ord() function** is a library function in Python, it accepts a character and returns it's ASCII value.

**Example:**

print(ord('A')) //returns 65

### 2) Python chr() function

**chr() function** is a library function in Python, it accepts a value (ASCII code) and returns characters.

**Example:**

print(chr(65)) //returns A

**Return value of chr(ord('A'))**

Statement chr(ord('A')) evaluation – ord('A') will return **65** and then chr(65) will return character value of ASCII code **65**, thus, it will return **'A'**.

**Python code to demonstrate example of chr() and ord() functions**

# python code to demonstrate example of # chr() and ord() function # printing ASCII codes c = 'A' print("ASCII value of " + c + " is = ", ord(c)) c = 'X' print("ASCII value of " + c + " is = ", ord(c)) c = 'a' print("ASCII value of " + c + " is = ", ord(c)) c = 'z' print("ASCII value of " + c + " is = ", ord(c)) # printing characters val = 65 print("CHAR value of ", val, " is = " + chr(val)) val = 88 print("CHAR value of ", val, " is = " + chr(val)) val = 97 print("CHAR value of ", val, " is = " + chr(val)) val = 122 print("CHAR value of ", val, " is = " + chr(val)) # chr(ord('A') print("value of the statement is: " + chr(ord('A')))

**Output**

ASCII value of A is = 65 ASCII value of X is = 88 ASCII value of a is = 97 ASCII value of z is = 122 CHAR value of 65 is = A CHAR value of 88 is = X CHAR value of 97 is = a CHAR value of 122 is = z value of the statement is: A

TOP Interview Coding Problems/Challenges

- Run-length encoding (find/print frequency of letters in a string)
- Sort an array of 0's, 1's and 2's in linear time complexity
- Checking Anagrams (check whether two string is anagrams or not)
- Relative sorting algorithm
- Finding subarray with given sum
- Find the level in a binary tree with given sum K
- Check whether a Binary Tree is BST (Binary Search Tree) or not
- 1[0]1 Pattern Count
- Capitalize first and last letter of each word in a line
- Print vertical sum of a binary tree
- Print Boundary Sum of a Binary Tree
- Reverse a single linked list
- Greedy Strategy to solve major algorithm problems
- Job sequencing problem
- Root to leaf Path Sum
- Exit Point in a Matrix
- Find length of loop in a linked list
- Toppers of Class
- Print All Nodes that don't have Sibling
- Transform to Sum Tree
- Shortest Source to Destination Path

Comments and Discussions

**Ad:**
Are you a blogger? Join our Blogging forum.

Learn PCB Designing: PCB DESIGNING TUTORIAL