Python, Robotics & Electronics Practice Booklet
Section 1: Python Basics Programs (Class 8–9
Level)
Print 'Hello World'
print("Hello, World!")
Add two numbers
a, b = 5, 7 print('Sum =', a+b)
Swap two numbers
a, b = 10, 20 a, b = b, a print('After swap:', a, b)
Area of rectangle
l, w = 5, 3 area = l * w print('Area =', area)
Area of circle
r = 7 area = 3.14 * r * r print('Area =', area)
Check even or odd
n = 12 if n % 2 == 0: print('Even') else: print('Odd')
Largest of 3 numbers
a, b, c = 12, 18, 7 print('Largest =', max(a, b, c))
Simple Interest
p, r, t = 1000, 5, 2 si = (p * r * t) / 100 print('Simple Interest =', si)
Sum of first 10 natural numbers
s = 0 for i in range(1, 11): s += i print('Sum =', s)
Multiplication table
n = 5 for i in range(1, 11): print(n, 'x', i, '=', n*i)
Reverse a string
s = 'python' print('Reversed =', s[::-1])
Count vowels in string
s = 'education' vowels = 'aeiou' count = 0 for ch in s: if ch in vowels: count += 1 print('Vowels =',
count)
Factorial (loop)
n = 5 fact = 1 for i in range(1, n+1): fact *= i print('Factorial =', fact)
Check palindrome
s = 'madam' if s == s[::-1]: print('Palindrome') else: print('Not Palindrome')
Fibonacci series
a, b = 0, 1 for i in range(10): print(a, end=' ') a, b = b, a+b
Average of list
lst = [10, 20, 30, 40] avg = sum(lst) / len(lst) print('Average =', avg)
Numbers divisible by 5 (1–50)
for i in range(1, 51): if i % 5 == 0: print(i, end=' ')
Check prime number
n = 13 prime = True for i in range(2, int(n**0.5)+1): if n % i == 0: prime = False break print('Prime' if
prime else 'Not Prime')
Sum of digits
n = 1234 s = 0 for d in str(n): s += int(d) print('Sum of digits =', s)
Celsius to Fahrenheit
c = 37 f = (c * 9/5) + 32 print('Fahrenheit =', f)
Section 2: Robotics Basics (Q & A)
Q: What is a robot?
A: A robot is a programmable machine capable of carrying out tasks automatically or
semi-automatically. Example: Industrial robot arms, cleaning robots.
Q: Difference between manual and autonomous robots
A: Manual robots are controlled by humans (e.g., RC car). Autonomous robots work without human
input (e.g., self-driving car).
Q: Name three types of sensors
A: Ultrasonic, Infrared, Touch sensors.
Q: What is an actuator?
A: Device that converts energy into motion (e.g., motors, hydraulic cylinders).
Q: Define servo motor
A: Motor with feedback for precise control of angle/position. Used in robotic arms, drones.
Q: Function of ultrasonic sensor
A: Measures distance using sound waves; helps in obstacle avoidance.
Q: What is Arduino?
A: An open-source microcontroller board used to control sensors, motors in robots.
Q: Explain line-following robot
A: Uses IR sensors to detect black/white line and moves accordingly.
Q: Difference between DC motor and stepper motor
A: DC motor rotates continuously. Stepper motor moves in precise steps.
Q: What is AI in robotics?
A: Artificial Intelligence enables robots to think, learn, and make decisions.
Q: Advantages and disadvantages of robots
A: ✔ Faster, safer in dangerous jobs. ✘ Expensive, may reduce jobs.
Q: Role of machine learning in robotics
A: Helps robots learn from data and improve performance.
Q: What are humanoid robots?
A: Robots designed like humans (e.g., Sophia, ASIMO).
Q: Define kinematics
A: Study of motion of robots without considering forces.
Q: What is swarm robotics?
A: Use of many simple robots working together like ants.
Q: Role of sensors in obstacle avoidance
A: Sensors detect objects and help robots avoid collisions.
Q: What is mechatronics?
A: Combination of mechanics, electronics, and computing to design systems.
Q: Microcontroller vs Microprocessor
A: Microcontroller: single chip with CPU, memory, I/O. Microprocessor: CPU only, external
components needed.
Q: Input vs Output devices in robotics
A: Input: Sensors. Output: Actuators, motors.
Q: Future of robotics
A: Robots will be more intelligent and widely used in industries, healthcare, daily life.
Section 3: Electronics Basics (Q & A)
Q: What is Ohm’s law?
A: Current is directly proportional to voltage. Formula: V = I × R.
Q: Define resistor
A: Resistor resists current flow. Symbol: zig-zag line.
Q: Types of resistors
A: Fixed, Variable (potentiometer), LDR.
Q: Define capacitor
A: Stores electrical energy. Used in filtering, energy storage.
Q: Function of diode
A: Allows current in one direction only.
Q: What is LED?
A: Light Emitting Diode – emits light when current flows.
Q: Define transistor
A: Semiconductor device used as a switch or amplifier. Types: NPN, PNP.
Q: AC vs DC current
A: AC changes direction; DC flows in one direction.
Q: What is breadboard?
A: Tool for building circuits without soldering.
Q: Series vs Parallel resistors
A: Series: connected one after another. Parallel: connected side by side.
Q: What is a power supply?
A: Device providing electrical energy (battery, adapter).
Q: Define relay
A: Electrically operated switch controlling high-power circuits using low-power signals.
Q: What is potentiometer?
A: Variable resistor used to adjust voltage.
Q: What is LDR?
A: Light Dependent Resistor; resistance decreases in light. Used in street lights.
Q: Define battery
A: Source of DC power. Symbol: long and short parallel lines.
Q: Explain short circuit
A: Fault where current flows through very low resistance, causing damage.
Q: Basic electronic components
A: Resistor, capacitor, diode, transistor, LED, battery, switch.
Q: Applications of capacitors
A: Used for energy storage, noise filtering.
Q: Analog vs Digital signals
A: Analog: continuous. Digital: discrete 0 and 1.
Q: Define multimeter
A: Instrument to measure voltage, current, resistance.