Robotics & Artificial Intelligence
From the following, which function of Python checks whether all characters in a string 's' are alpha numeric?
- s.allnum()
- s.isnumal()
- s.isalnum()
- s.isalphanum()
Answer
s.isalnum()
Reason — The function isalnum() is used to check whether all characters in a string are alphanumeric (i.e., letters and numbers). It returns True if all characters are either alphabets or digits, otherwise it returns False. The other options are incorrect because they are not valid Python string methods.
Related Questions
In the block diagram of a robotic control system, the correct sequence is:
- Input → Robot → Controller → Feedback
- Feedback → Input → Controller → Robot
- Input → Controller → Robot → Feedback
- Controller → Input → Robot → Feedback
Which of the following is an example of a linear actuator?
- DC motor
- Pneumatic piston
- Arduino
- Electric fan
A motor drives a small gear with 10 teeth which is connected to a larger gear with 40 teeth. What is the gear ratio?
- 4 : 1
- 1 : 4
- 1 : 2
- 2 : 1
Which of the following string operators in Python is used to find the length of a string 'a'?
- len(a)
- len()
- a.len()
- a.len(a)