8000 GitHub - jonibek99/python_module_homework
[go: up one dir, main page]

Skip to content

jonibek99/python_module_homework

 
 

Repository files navigation

Welcome to Python Module Homework

This repository contains a set of 10 tasks that involve using the math module. To complete the homework, follow the instructions below:

  1. Fork this repository to your own GitHub account.
  2. Solve each task by writing the required code.
  3. Commit your solutions with appropriate commit messages.
  4. Push the changes to your GitHub repository.
  5. Submit the link to your repository for grading.

Task 1: Square Root Calculation

Write a Python program that calculates the square root of a given number using the math module.

# Calculate the square root of a number

# Example usage
input_number = 16
result = calculate_square_root(input_number)
print(result) # Output: 4.0

Task 2: Factorial Calculation

Write a Python program that calculates the factorial of a given number using the math module.

# Calculate the factorial of a number

# Example usage
input_number = 5
result = calculate_factorial(input_number)
print(result) # Output: 120

Task 3: Trigonometric Calculations

Write a Python program that calculates the sine, cosine, and tangent of an angle using the math module.

# Perform trigonometric calculations

# Example usage
input_angle = 45
sine, cosine, tangent = perform_trigonometric_calculations(input_angle)
print("Sine:", sine)  # Output: 0.7071067811865475
print("Cosine:", cosine)  # Output: 0.7071067811865476
print("Tangent:", tangent)  # Output: 0.9999999999999999

Task 4: Logarithm Calculation

Write a Python program that calculates the logarithm of a number to a specified base using the math module.

# Calculate the logarithm of a number\

# Example usage
input_number = 100
input_base = 10
result = calculate_logarithm(input_number, input_base)
print(result)  # Output: 2.0

Task 5: Exponential Calculation

Write a Python program that calculates the exponential value of a number using the math module.

# Calculate the exponential value of a number

# Example usage
input_number = 2
result = calculate_exponential(input_number)
print(result)  # Output: 7.3890560989306495

Task 6: Round to Nearest Integer

Write a Python program that rounds a decimal number to the nearest integer using the math module.

# Round a decimal number to the nearest integer

# Example usage
input_number = 3.7
result = round_to_nearest_integer(input_number)
print(result)  # Output: 4

Task 7: Ceiling and Floor Calculation

Write a Python program that calculates the ceiling and floor values of a number using the math module.

# Calculate the ceiling and floor values of a number

# Example usage
input_number = 4.3
ceiling, floor = calculate_ceiling_floor(input_number)
print("Ceiling:", ceiling)  # Output: 5
print("Floor:", floor)  # Output: 4

Task 8: Degree to Radian Conversion

Write a Python program that converts an angle from degrees to radians using the math module.

# Convert an angle from degrees to radians

# Example usage
input_degrees = 90
result = convert_degrees_to_radians(input_degrees)
print(result)  # Output: 1.5707963267948966

Task 9: Radian to Degree Conversion

Write a Python program that converts an angle from radians to degrees using the math module.

# Convert an angle from radians to degrees

# Example usage
input_radians = 1.5707963267948966
result = convert_radians_to_degrees(input_radians)
print(result)  # Output: 90.0

Task 10: Power Calculation

Write a Python program that calculates the power of a number using the math module.

# Calculate the power of a number

# Example usage
input_base = 2
input_exponent = 3
result = calculate_power(input_base, input_exponent)
print(result)  # Output: 8.0

Once you have completed all the tasks, your homework will be ready for submission. Good luck!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%
0