Python Programming - Console Input/Output
Exercise : Console Input/Output - General Questions
- Console Input/Output - General Questions
36.
How can you remove all occurrences of a specific character from a string?
Answer: Option
Explanation:
To remove all occurrences of a specific character from a string, use the
replace()
method.
37.
How can you check if a string is a valid email address?
Answer: Option
Explanation:
To check if a string is a valid email address, you can use a regular expression pattern with
re.match()
.
38.
How can you print the ASCII values of all characters in a string?
Answer: Option
Explanation:
To print the ASCII values of all characters in a string, use a loop to iterate through each character and print its ASCII value using
ord()
.
39.
How can you read multiple integers from the console and store them in a list?
Answer: Option
Explanation:
To read multiple integers from the console and store them in a list, use
list(map(int, input().split()))
.
40.
How can you format a floating-point number with a specific number of decimal places?
Answer: Option
Explanation:
To format a floating-point number with a specific number of decimal places, use
format(number, ".2f")
.
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers