write a program to print hello world
# This program prints Hello, World!
print("Hello, World!")
Write a program to check the given number is odd or even
# Program to check if a number is odd or even
# Take input from the user
num = int(input("Enter a number: "))
# Check if the number is even or odd
if num % 2 == 0:
print(f"{num} is Even")
else:
print(f"{num} is Odd")
Write a program to check whether the given number is fully divisible by 5 or not
# Program to check if a number is divisible by 5
# Take input from the user
num = int(input("Enter a number: "))
# Check divisibility
if num % 5 == 0:
print(f"{num} is fully divisible by 5")
else:
print(f"{num} is NOT fully divisible by 5")
write a program to print conversion of weight from kilogram to grams
kg = float(input("Enter weight in kilograms: "))
# Convert to grams
grams = kg * 1000
# Display result
print(f"{kg} kilograms is equal to {grams} grams")
write a program to take two number and finds greater number
# Program to find the greater of two numbers
# Take input from the user
num1 = float(input("Enter first number: "))
num2 = float(input("Enter second number: "))
# Compare the two numbers
if num1 > num2:
print(f"{num1} is greater than {num2}")
elif num2 > num1:
print(f"{num2} is greater than {num1}")
else:
print("Both numbers are equal")
Write a program to print the table of any given number
# Program to print the multiplication table of a given number
# Take input from the user
num = int(input("Enter a number: "))
# Print the table
print(f"Multiplication Table of {num}:")
for i in range(1, 11):
print(f"{num} x {i} = {num * i}")
Write a program to print the sum of all digits of given number for example if the user inputs158 then the
sum will be 1+5+8=14
# Program to find the sum of all digits of a number
# Take input from the user
num = input("Enter a number: ")
# Calculate the sum of digits
sum_of_digits = 0
for digit in num:
sum_of_digits += int(digit)
# Display the result
print(" + ".join(num), "=", sum_of_digits)
Write a program to find perimeter and area of a rectangle
# Program to find the perimeter and area of a rectangle
# Take input from the user
length = float(input("Enter the length of the rectangle: "))
width = float(input("Enter the width of the rectangle: "))
# Calculate perimeter and area
perimeter = 2 * (length + width)
area = length * width
# Display results
print(f"Perimeter of the rectangle = {perimeter}")
print(f"Area of the rectangle = {area}")
Write a program to find the given number is positive or negative
# Program to check if a number is positive or negative
# Take input from the user
num = float(input("Enter a number: "))
# Check the sign of the number
if num > 0:
print(f"{num} is Positive")
elif num < 0:
print(f"{num} is Negative")
else:
print("The number is Zero")
Write the program to find the temperature from Fahrenheit to Celsius
# Program to convert Fahrenheit to Celsius
# Take input from the user
fahrenheit = float(input("Enter temperature in Fahrenheit: "))
# Convert to Celsius
celsius = (fahrenheit - 32) * 5 / 9
# Display result
print(f"{fahrenheit}°F is equal to {celsius:.2f}°C")
Write a program to calculate simple interest
# Program to calculate Simple Interest
# Take input from the user
principal = float(input("Enter the principal amount: "))
rate = float(input("Enter the rate of interest (in %): "))
time = float(input("Enter the time period (in years): "))
# Calculate simple interest
simple_interest = (principal * rate * time) / 100
# Display result
print(f"Simple Interest = {simple_interest}")