Programming Essentials
Programming Essentials
1. Write a program which reads two integer values. If the first number is less than
the second, print the message "First number is less than the second".
If the second is less than the first, print the message "Second number is less
than the first".
If the numbers are equal, print the message "The numbers are equal".
Program :
Result :
2. Write a program that prompts the user to enter age. If age of the user is equal to
or greater than 18, then the proram displays “You are eligibel to vote”. Otherwise
the program displays “You cannot vote”.
Program :
3. The Young and Beautiful Travel Company restricts its clients to ages between 18
and 30. Write a program to input a client's age and test whether they are eligible
to go on vacation with the company or not.
Program :
Result:
4. Write a program to input a salary from the user and determine how much tax
someone should pay according to the following rules:
People pay no tax if they earn up to €10,000. They pay tax at the rate of 20% on the
amount they earn over €10,000 but up to €50,000. They pay tax at 40% on any money
they earn over €50,000.
Program:
Result:
Program:
Result:
6. Write a program which displays a menu to the user. The menu should look
similar to the following:
Program:
if choice == '1':
result = num1 + num2
print(f"The result of adding {num1} and {num2} is {result}")
elif choice == '2':
result = num1 - num2
print(f"The result of subtracting {num2} from {num1} is {result}")
elif choice == '3':
if num2 != 0:
result = num1 / num2
print(f"The result of dividing {num1} by {num2} is {result}")
else:
print("Error: Division by zero is not allowed.")
elif choice == '4':
result = num1 * num2
print(f"The result of multiplying {num1} and {num2} is {result}")
else:
print("Invalid choice. Please choose a number between 1 and 4.")
Result: