Python: Compute the sum of the ASCII values of the upper-case characters in a given string
Sum of ASCII for Uppercase Letters
Write a Python program to compute the sum of the ASCII values of the upper-case characters in a given string.
Input: PytHon ExerciSEs Output: 373 Input: JavaScript Output: 157
Visual Presentation:
Sample Solution-1:
Python Code:
Sample Output:
Original strings: PytHon ExerciSEs Sum of the ASCII values of the upper-case characters in the said string: 373 Original strings: JavaScript Sum of the ASCII values of the upper-case characters in the said string: 157
Flowchart:
Sample Solution-2:
Python Code:
Sample Output:
Original strings: PytHon ExerciSEs Sum of the ASCII values of the upper-case characters in the said string: 373 Original strings: JavaScript Sum of the ASCII values of the upper-case characters in the said string: 157 Original strings: ARt Sum of the ASCII values of the upper-case characters in the said string: 147
Flowchart:
Sample Solution-3:
Python Code:
Sample Output:
Original strings: PytHon ExerciSEs Sum of the ASCII values of the upper-case characters in the said string: 373 Original strings: JavaScript Sum of the ASCII values of the upper-case characters in the said string: 157 Original strings: ARt Sum of the ASCII values of the upper-case characters in the said string: 147
Flowchart:
For more Practice: Solve these Related Problems:
- Write a Python program to calculate the sum of ASCII values of all uppercase letters in a string using ord().
- Write a Python program to filter out uppercase characters from a string and compute their cumulative ASCII sum.
- Write a Python program to use a loop to add ASCII values for each uppercase character in an input string.
- Write a Python program to implement the ASCII sum calculation using list comprehension and the sum() function.
Go to:
Previous: Determine, for each string in a list, whether the last character is an isolated letter.
Next: Find the indices for which the numbers in the list drops.
Python Code Editor :
Have another way to solve this solution? Contribute your code (and comments) through Disqus.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.