Skip to content

sasikanth6076/Assignment-3-Functions-Modules-in-Python

Repository files navigation

Assignment-3-Functions-Modules-in-Python

This respository contains the python codes for Assignment 3: Functions & Modules in Python

ASSIGNMENT 3:

Module 4: Functions & Modules in Python

Task 1: Calculate Factorial Using a Function

Problem Statement: Write a Python program that:

  1. Defines a function named factorial that takes a number as an argument and calculates its factorial using a loop or recursion.
  2. Returns the calculated factorial.
  3. Calls the function with a sample number and prints the output.

Expected Output:

for example, if the function is called with 5, it should return

Enter a number: 5 Factorial of 5 is: 120


Task 2: Using the Math Module for Calculations

Problem Statement: Write a Python program that:

  1. Asks the user for a number as input.
  2. Uses the math module to calculate the: o Square root of the number o Natural logarithm (log base e) of the number o Sine of the number (in radians)
  3. Displays the calculated results.

Expected Output:

For example, if the user enters 25, the output should be:

Enter a number: 25 Square root: .50 logarithm: 3.2188758248682006 sine: -0.13235175009777303

About

This respository contains the python codes for Assignment 3: Functions & Modules in Python

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages