A simple program that prints a fixed message. python Copy code # Print a message print("Python is fun!")
2. Multiply Two Numbers
A program that multiplies two numbers. python Copy code # Input two numbers a = int(input("Enter first number: ")) b = int(input("Enter second number: "))
# Multiply the numbers
result = a * b
# Print the result
print(f"The result of multiplying {a} and {b} is {result}.") 3. Print a Number A program that takes a number as input and prints it. python Copy code # Input a number num = input("Enter a number: ") # Print the number print(f"You entered: {num}") 4. Check if a Number is Zero This program checks if the input number is zero. python Copy code # Input a number num = int(input("Enter a number: "))
# Check if the number is zero
if num == 0: print("The number is zero.") else: print("The number is not zero.") 5. Simple Addition Program A program to add two fixed numbers and display the result. python Copy code # Add two numbers result = 5 + 10
# Print the result
print(f"5 + 10 = {result}") 6. Print the First 5 Natural Numbers This program prints the first 5 natural numbers (1 to 5). python Copy code # Print numbers from 1 to 5 print(1) print(2) print(3) print(4) print(5) 7. Check if a Number is Positive A program to check if a number is positive. python Copy code # Input a number num = int(input("Enter a number: "))
# Check if the number is positive
if num > 0: print("The number is positive.") else: print("The number is not positive.") 8. Print a List of Items This program prints a list of items (fruits in this case). python Copy code # Print a list of fruits print("Apple") print("Banana") print("Orange") print("Grapes") 9. Subtract Two Numbers A program to subtract two numbers provided by the user. python Copy code # Input two numbers a = int(input("Enter first number: ")) b = int(input("Enter second number: "))
# Subtract the numbers
result = a - b
# Print the result
print(f"The result of subtracting {b} from {a} is {result}.") 10. Check if a Number is Greater than 10 This program checks if a number is greater than 10. python Copy code # Input a number num = int(input("Enter a number: "))
# Check if the number is greater than 10
if num > 10: print(f"{num} is greater than 10.") else: print(f"{num} is not greater than 10.")