Python Programming - Console Input/Output

Exercise : Console Input/Output - General Questions
  • Console Input/Output - General Questions
16.
How can you check if a string is numeric?
isnumeric()
numeric_check()
str.isnumeric()
isdigit()
Answer: Option
Explanation:
You can use str.isnumeric() to check if a string is numeric in Python.

17.
What will happen if you use the int() function to convert a non-numeric string?
Error: Cannot convert non-numeric string to integer
The string will be converted to 0
The program will terminate
The string will be printed as is
Answer: Option
Explanation:
Using int() on a non-numeric string will result in a ValueError.

18.
How can you read a character from the console?
input_char()
char(input())
input()[0]
read_character()
Answer: Option
Explanation:
To read a character from the console in Python, you can use input()[0] to get the first character of the input string.

19.
How can you print the Unicode representation of a character?
unicode_print('A')
ord('A')
print_unicode('A')
unicode('A')
Answer: Option
Explanation:
The ord() function in Python is used to get the Unicode code point of a character.

20.
How can you convert a string to lowercase?
str.lowercase()
convert_lowercase(str)
str.lower()
lower(str)
Answer: Option
Explanation:
The lower() method is used to convert a string to lowercase in Python.