Question 1:
Write a Python program to print "Hello, World!" to the console.
Solution:
print("Hello, World!")
Question 2:
Write a Python program to calculate the sum of two numbers entered by the user.
Solution:
num1 = float(input("Enter the first number: "))
num2 = float(input("Enter the second number: "))
sum = num1 + num2
print("The sum is:", sum)
Question 3:
Write a Python program to check if a given number is even or odd.
Solution:
num = int(input("Enter a number: "))
if num % 2 == 0:
print(num, "is even")
else:
print(num, "is odd")
Question 4:
Write a Python program to find the factorial of a given number.
Solution:
num = int(input("Enter a number: "))
factorial = 1
for i in range(1, num + 1):
factorial *= i