Check whether the given character is in upper case or lower case or noneInput Format:Enter a Character as inputOutput Format:Print the output as "UPPERCASE" or "LOWERCASE" or "NONE"Constraints:0 <= INPUT <= 2^7Sample Input 1:ZSample Output 1:UPPERCASESample Input 2:zSample Output 2:LOWERCASE
Question
Check whether the given character is in upper case or lower case or noneInput Format:Enter a Character as inputOutput Format:Print the output as "UPPERCASE" or "LOWERCASE" or "NONE"Constraints:0 <= INPUT <= 2^7Sample Input 1:ZSample Output 1:UPPERCASESample Input 2:zSample Output 2:LOWERCASE
Solution
To check whether the given character is in uppercase or lowercase or none, follow these steps:
- Read the input character.
- Check if the ASCII value of the character lies between 65 and 90 (inclusive). If it does, then the character is an uppercase letter.
- Check if the ASCII value of the character lies between 97 and 122 (inclusive). If it does, then the character is a lowercase letter.
- If the character does not fall into either of the above ranges, then it is neither uppercase nor lowercase.
- Print "UPPERCASE" if the character is uppercase, "LOWERCASE" if the character is lowercase, or "NONE" if the character is neither.
Here is the code implementation in Python:
# Step 1: Read the input character
character = input("Enter a character: ")
# Step 2: Check if the character is uppercase
if ord(character) >= 65 and ord(character) <= 90:
print("UPPERCASE")
# Step 3: Check if the character is lowercase
elif ord(character) >= 97 and ord(character) <= 122:
print("LOWERCASE")
# Step 4: Character is neither uppercase nor lowercase
else:
print("NONE")
Sample Input 1:
Z
Sample Output 1:
UPPERCASE
Sample Input 2:
z
Sample Output 2:
LOWERCASE
Similar Questions
Check whether the given character is an alphabet or a numeric character or special characterInput Format:Enter a Character as inputOutput Format:Print the output as "NUMBER" or "ALPHABET" or "SPECIAL CHARACTER"Constraints:0 <= CHARACTER <= 2^7Sample Input 1:7Sample Output 1:NUMBERSample Input 2:aSample Output 2:ALPHABET
Write a program to print the duplicate characters in the given stringInput FormatGiven a stringOutput Formatprint the duplicate characters separated by space ':'Constraint :1 <= string length <= 100Note: If more than one occurred then print the first occurrencethe string might have upper case letter that should be considered as lowercase
Input FormatA single line containing a string .ConstraintsOutput FormatIn the first line, print True if has any alphanumeric characters. Otherwise, print False.In the second line, print True if has any alphabetical characters. Otherwise, print False.In the third line, print True if has any digits. Otherwise, print False.In the fourth line, print True if has any lowercase characters. Otherwise, print False.In the fifth line, print True if has any uppercase characters. Otherwise, print False.
Problem StatementSuresh is working on a program that checks the case of an input character. He needs a simple solution that uses a function called check() to determine whether the given character is in uppercase, lowercase, or invalid. Can you assist Suresh in creating this program?Note: This question helps in clearing technical coding tests for companies like Wipro.Input format :The input consists of a single character.Output format :The output is a single line indicating the case of the input character. It can be one of the following:"Upper Case" if the input character is an uppercase letter."Lower Case" if the input character is a lowercase letter."Invalid" if the input character is neither an uppercase nor a lowercase letter.Refer to the sample outputs for formatting specifications.Sample test cases :Input 1 :aOutput 1 :Lower CaseInput 2 :VOutput 2 :Upper CaseInput 3 :$Output 3 :InvalidInput 4 :5Output 4 :InvalidNote :The program will be evaluated only after the “Submit Code” is clicked.Extra spaces and new line characters in the program output will result in the failure of the test case.Marks : 10Negati
Given a positive integer denoting , do the following:If , print the lowercase English word corresponding to the number (e.g., one for , two for , etc.).If , print Greater than 9.Input FormatThe first line contains a single integer, .ConstraintsOutput FormatIf , then print the lowercase English word corresponding to the number (e.g., one for , two for , etc.); otherwise, print Greater than 9 instead.Sample Input5Sample OutputfiveSample Input #018Sample Output #01eightSample Input #0244Sample Output #02Greater than 9
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.