Computer Science, asked by Anonymous, 1 year ago

write a program in phyton to take as input a character and determine the entered character is an alphabet or a digit or any non -zero character.
please do the program correctly. ​

Answers

Answered by darkcrafter09
1

IN PYTHON:

char = input("Please type your character here: ")

if (char>='A' and char<='Z') or (char>='a' and char<='z'):

   print ("Its an alphabet)

else if (char>='0' and char<='9'):

   print ("Its a number)

else:

   print ("Its a non-zero character")

IN C++:

#include <bits/stdc++.h>

using namespace std;

int main() {

   string char;

   cout << "Please type your character here: ");

   cin >> char;

   if ((char>='A' && char<='Z') || (char>='a' && char<='z')) cout << "Alphabet" <<       endl;

   else if (char>='0' && char<='9') cout << "Number" << endl;

   else cout << "Non-zero character" << endl;

   return 0;

}


Anonymous: thanks for the answer
darkcrafter09: Sorry, I left some characters in the python code.
darkcrafter09: Here is the completely working code
Similar questions