0% found this document useful (0 votes)
9 views2 pages

Python Basic Arithmetic and Age Checker

The document contains two Python programs: the first program reads two numbers and performs basic arithmetic operations (addition, subtraction, multiplication, division) based on user choice, while handling division by zero errors. The second program reads a person's name and year of birth, then determines if the person is a senior citizen (60 years or older) based on the current year of 2025. Both programs utilize user input and conditional statements to execute their functionalities.

Uploaded by

noobkolof
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views2 pages

Python Basic Arithmetic and Age Checker

The document contains two Python programs: the first program reads two numbers and performs basic arithmetic operations (addition, subtraction, multiplication, division) based on user choice, while handling division by zero errors. The second program reads a person's name and year of birth, then determines if the person is a senior citizen (60 years or older) based on the current year of 2025. Both programs utilize user input and conditional statements to execute their functionalities.

Uploaded by

noobkolof
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

1. a.

Develop a python program to read 2 numbers from the keyboard and perform the basic arithmetic

operations based on the choice. (1-Add, 2-Subtract, 3-Multiply, 4-Divide).

# Program to perform basic arithmetic operations

# Read two numbers from the user

num1 = int(input("Enter the first number: "))

num2 = int(input("Enter the second number: "))

# Display menu of operations

print("\nChoose an operation:")

print("1. Add")

print("2. Subtract")

print("3. Multiply")

print("4. Divide")

# Read user choice

choice = int(input("Enter your choice (1-4): "))

# Perform the operation

if choice == 1:

result = num1 + num2

print("The result of addition is:",result)

elif choice == 2:

result = num1 - num2

print(f"The result of subtraction is: {result}")

elif choice == 3:

result = num1 * num2

print(f"The result of multiplication is: {result}")

elif choice == 4:

if num2 != 0:

result = num1 / num2

print(f"The result of division is: {result}")

else:

print("Error: Division by zero is not allowed.")

else:

print("Invalid choice! Please enter a number between 1 and 4.")


1 b. Develop a program to read the name and year of birth of a person. Display whether the person is a

senior citizen or not.

name=input('Enter your name:')

born_year= int(input('Enter your born year:'))

current_year=2025

age=current_year-born_year

if age>=60:

print('Senior citizen')

else:

print('not a senior citizen')

You might also like