Sample python program for practice
[Link] program for prime number
2. Program for checking of even odd
3. Program for checking Armstrong
number
4. Program for checking biggest
number in given two numbers
[Link] the factorial of a given
number
6. calculate the average of given two
numbers.
7. add or substract any element in
the given list
8. Practice list slicing.
9. practice some output based
question from book.
Examples
1. Question
x = 5
y = 2
print(x + y * 3)
Answer:
11
Explanation:
Multiplication happens first → 2 * 3 = 6, then 5 + 6 = 11.
2. Question
a = "Hello"
b = "World"
print(a + " " + b)
Answer:
Hello World
Explanation:
Strings are concatenated using +.
3. Question
num = 10
if num > 5:
print("A")
else:
print("B")
Answer:
Explanation:
Since 10 > 5, the if block executes.
4. Question
for i in range(3):
print(i, end=" ")
Answer:
0 1 2
Explanation:
range(3) generates numbers 0, 1, 2.
5. Question
x = [1, 2, 3]
print(len(x))
Answer:
Explanation:
The list contains 3 elements.