Skip to content

JatinKumar4/python-module4-assignment

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

Python Functions & Math Module Programs

This repository contains two Python scripts developed as part of Module 4: Functions & Modules in Python.


Task 1: Factorial Calculation Using a Function

File: task1_factorial.py

This script defines a recursive function factorial(number) that calculates the factorial of a given non-negative integer.

  • Handles negative inputs by returning an error message.
  • Uses recursion with a base case of factorial(0) = 1.
  • Prints the factorial of a sample number (e.g., 5).

Example output: The factorial of 5 is: 120


Task 2: Math Module Calculations

File: task2_math_module.py

This script:

  • Takes a number input from the user.
  • Validates the input to ensure the square root and natural logarithm can be calculated.
  • Calculates and displays:
    • Square root of the number
    • Natural logarithm (base e) of the number
    • Sine of the number (in radians)

Example interaction: Enter the number: 25 Square root of 25.0 is: 5.0 Natural logarithm of 25.0 is: 3.2188758248682006 Sine of 25.0 radians is: -0.13235175009777303

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages