numbers = [1, 2, 3, 4, 5]
for num in numbers:
remainder = num % 2
if remainder == 0:
print(num, "is divisible by 2")
else:
print("The remainder when", num, "is divided by 2 is", remainder)
The remainder when 1 is divided by 2 is 1
2 is divisible by 2
The remainder when 3 is divided by 2 is 1
4 is divisible by 2
The remainder when 5 is divided by 2 is 1
def fibonacci(n):
a, b = 0, 1
for _ in range(n - 1):
a, b = b, a + b
return a
term = int(input("Enter the term of the Fibonacci sequence: "))
print(f"The Fibonacci number at position {term} is {fibonacci(term)}.")
def calculate_area():
shape = input("Enter the shape (circle, square, rectangle): ").lower()
if shape == "circle":
radius = float(input("Enter the radius: "))
area = 3.14 * radius ** 2
elif shape == "square":
side = float(input("Enter the side length: "))
area = side ** 2
elif shape == "rectangle":
length = float(input("Enter the length: "))
width = float(input("Enter the width: "))
area = length * width
else:
return "Invalid shape."
print(f"The area of the {shape} is: {area}")
calculate_area()
The Fibonacci number at position 5 is 3.
The area of the circle is: 50.24
The volume of the sphere is: 523.60