0% found this document useful (0 votes)
5 views3 pages

A Python Program That Computes Square Root

The document presents a Python program that allows users to compute the square root, logarithm, and factorial of a number. It prompts the user to select a calculation type and handles invalid inputs appropriately. The program uses the math library for the calculations and provides rounded results for square roots and logarithms.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views3 pages

A Python Program That Computes Square Root

The document presents a Python program that allows users to compute the square root, logarithm, and factorial of a number. It prompts the user to select a calculation type and handles invalid inputs appropriately. The program uses the math library for the calculations and provides rounded results for square roots and logarithms.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

A Python Program that Computes Square root, Log and Factorial

Student name

Institution affiliation

Due date
import math

print("Welcome to the simple math helper.\nWhat would you like to calculate?")

print("1. Sqrt \n2. Log \n3. Factorial")

choice = input(">")

if choice == "1":

num = float(input("Enter the number to Sqrt:"))

if num>=0:

result =math.sqrt(num)

print(round(result,1))

else:

print("Invalid option")

elif choice =="2":

num = float(input("Enter the number to Log:"))

if num>0:

result =math.log(num)

print(round(result,1))

else:

print("Invalid option")

elif choice == "3":

num = int(input("Enter the number to factorial:"))

if num>=0:

result =math.factorial(num)

print(result)

else:

print("Invalid option")

else:
print("Wrong Choice./n You can only input 1,2 or 3")

You might also like