Character Code

Character Code

Easy Python Data Types 10 views
Explanation Complexity

Problem Statement

One character ch is provided. Output its ASCII/Unicode code using ord().

Input Format

• First line: A single character ch

Output Format

• Print one integer: ASCII / Unicode code of the character

Example

A
65

Constraints

• Input is exactly one character

Concept Explanation

Input:
ch = 'A'

Using ord('A') gives 65,
which is the ASCII (Unicode) value of character A.

Step-by-Step Explanation

1.Read character ch.

2.Use ord(ch) to get its ASCII/Unicode value.

3.Print the result.

Concept Explanation

Input:
ch = 'A'

Using ord('A') gives 65,
which is the ASCII (Unicode) value of character A.

Step-by-Step Explanation

1.Read character ch.

2.Use ord(ch) to get its ASCII/Unicode value.

3.Print the result.

Input / Output Format

Input Format
• First line: A single character ch
Output Format
• Print one integer: ASCII / Unicode code of the character
Constraints
• Input is exactly one character

Examples

Input:
A
Output:
65

Example Solution (Public)

Python
import sysns=sys.stdin.read()nif not s: sys.exit(0)nch=s.strip()[:1]nif not ch: sys.exit(0)nsys.stdout.write(str(ord(ch)))

Official Solution Code

import sysns=sys.stdin.read()nif not s: sys.exit(0)nch=s.strip()[:1]nif not ch: sys.exit(0)nsys.stdout.write(str(ord(ch)))
Please login to submit solutions.
Editor
Output

                                        
Please login to submit solutions.