• Profile
  • Resume
  • Portfolio
  • Blog
Avatar

Nelson Silva

A human. Being. Coffee lover.

Blog

I Write My Thoughts Here

Math Functions in Python

October 18, 2021 Python

In this post, you will learn how to work with math functions so that you can use that same knowledge and thus evolve.

sin(variable) Calculate the sine
cos(variable) Calculate the cosine
tan(variable) Calculate the tangent
floor(variable) Remove decimal value from given number
ceil(variable) Round the given number to the next
abs(variable) Returns the absolute value of the given number
fsum(variable) Sum all numbers within a list (for example)
pow(variableA, variableB) Multiplies its initial value multiple times (depending on the number of times)
from math import *

numbers = [10, 20, 30, 40, 50]

print('Result of the sin() function:', sin(10.5)) # Result of the sin() function: -0.87969575997167
print('Result of the cos() function:', cos(10.5)) # Result of the cos() function: -0.4755369279959925
print('Result of the tan() function:', tan(10.5)) # Result of the tan() function: 1.8498999934219273
print('Result of the floor() function:', floor(10.5)) # Result of the floor() function: 10
print('Result of the ceil() function:', ceil(10.5)) # Result of the ceil() function: 11
print('Result of the abs() function:', abs(-10.5)) # Result of the abs() function: 10.5
print('Result of the fsum() function:', fsum(numbers)) # Result of the fsum() function: 150.0
print('Result of the pow() function:', pow(2, 5)) # Result of the pow() function: 32.0

Don’t forget to watch the video and you can always read this post in Portuguese.

Happy coding!

Previous Next

Categories

  • Announcements
  • Python
  • C#
  • Java
  • Go

Latest Posts

  • for Loop in Go
    May 5, 2022
  • Switch in Go
    May 4, 2022
  • Comparison Operators in Go
    May 3, 2022
+351913416022
contact@nelsonsilvadev.com
Porto, Portugal
Nelson Silva © 2022 All Rights Reserved