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?
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?
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?
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?
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?
Answer: Option
Explanation:
The
lower()
method is used to convert a string to lowercase in Python.
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers