Write a Python program to check whether a number is divisible by 5 and 11 or not.
Write a Python program to check whether a number is divisible by 5 and 11 or not. SOLUTION…. # Program to check divisibility by 5 and 11 # Input num = int(input(“Enter a number: “)) # Check divisibility if num % 5 == 0 and num % 11 == 0: print(“number is divisible by both […]
Write a python program to find maximum between three numbers.
Write a python program to find maximum between three numbers. SOLUTION…. # Program to find maximum among three numbers using if-else # Input a = float(input(“Enter first number: “)) b = float(input(“Enter second number: “)) c = float(input(“Enter third number: “)) # Logic using if-else if a >= b and a >= c: print(“A is […]
Write a Python program to enter radius of a circle and find its diameter, circumference and area.
Write a Python program to enter radius of a circle and find its diameter, circumference and area. SOLUTION…. # Program to calculate diameter, circumference and area of a circle import math # for using pi # Input radius = float(input(“Enter the radius of the circle: “)) # Calculations diameter = 2 * radius circumference = […]
Write a Python program to calculate area of an equilateral triangle.
Write a Python program to calculate area of an equilateral triangle. SOLUTION…. # Program to calculate area of an equilateral triangle import math # for square root function # Input side = float(input(“Enter the side of the equilateral triangle: “)) # Formula: (√3 / 4) × side² area = (math.sqrt(3) / 4) * (side ** […]
Write a Python program to enter two angles of a triangle and find the third angle.
Write a Python program to enter two angles of a triangle and find the third angle. SOLUTION…. # Program to find third angle of a triangle # Input angle1 = float(input(“Enter first angle of triangle: “)) angle2 = float(input(“Enter second angle of triangle: “)) # Formula: Sum of angles of a triangle = 180 angle3 […]
Write a Python program to enter two numbers and perform all arithmetic operations.
Write a Python program to enter two numbers and perform all arithmetic operations. SOLUTION…. # Program to perform all arithmetic operations on two numbers # Input a = float(input(“Enter first number: “)) b = float(input(“Enter second number: “)) # Arithmetic operations stored in different variables addition = a + b subtraction = a – b […]
Write a Python program to enter length and breadth of a rectangle and find its Perimeter and Area .
Write a Python program to enter length and breadth of a rectangle and find its Perimeter and Area . SOLUTION…. # Program to calculate Area and Perimeter of a Rectangle # Input values length = float(input(“Enter length of rectangle: “)) breadth = float(input(“Enter breadth of rectangle: “)) # Calculations area = length * breadth perimeter […]
Write a Python program to enter P, T, R and calculate Simple Interest.
Write a Python program to enter P, T, R and calculate Simple Interest. SOLUTION…. # Input values P = float(input(“Enter Principal amount (P): “)) T = float(input(“Enter Time (T in years): “)) R = float(input(“Enter Rate of Interest (R): “)) # Formula for Simple Interest SI = (P * T * R) / 100 # […]
Write a Python program to enter temperature in Celsius and convert it into Fahrenheit and Vice Versa.
Write a Python program to enter temperature in Celsius and convert it into Fahrenheit and Vice Versa. SOLUTION…. # Fahrenheit to Celsius fahrenheit = float(input(“Enter temperature in Fahrenheit: “)) celsius = (fahrenheit – 32) * 5/9 print(f”{fahrenheit}°F = {celsius:.2f}°C”) # Celsius to Fahrenheit celsius = float(input(“nEnter temperature in Celsius: “)) fahrenheit = (celsius * 9/5) […]
Write a program to maintain a telephone directory. Use class and object with methods add() and show() to manage entries.
Write a program to maintain a telephone directory. Use class and object with methods add() and show() to manage entries. SOLUTION…. #include <iostream> #include <string> using namespace std; class Directory { private: string name[100]; string phone[100]; int count; public: Directory() { count = 0; } // Method to add entry void add() { if (count […]
